Configuration

GLEStyleConfig

class gleplot.GLEStyleConfig(font='', fontsize=12, default_linewidth=1.5, default_color=None, default_marker_color=None, line_style_solid=1, line_style_dashed=3, line_style_dotted=2, line_style_dashdot=6, line_cap=None, line_join=None, dashlen=None, usetex=False)[source]

GLE rendering style configuration.

Parameters:
  • font (str)

  • fontsize (float)

  • default_linewidth (float)

  • default_color (str | None)

  • default_marker_color (str | None)

  • line_style_solid (int)

  • line_style_dashed (int)

  • line_style_dotted (int)

  • line_style_dashdot (int)

  • line_cap (str | None)

  • line_join (str | None)

  • dashlen (float | None)

  • usetex (bool)

font

GLE font name (e.g., ‘texcmr’, ‘ss’, ‘psh’), not a family name such as ‘helvetica’, which GLE rejects. If None or empty string, uses GLE’s default font. Default: ‘’

Type:

str or None

fontsize

Font size in points. Default: 12 (optimized for GLE/PDF readability)

Type:

float

default_linewidth

Default line width in points (unit: 1/72 inch). Default: 1.5 points ≈ 0.053 cm (increased for visibility in PDFs)

Type:

float

default_color

Colour every series that takes its colour from the line cycle (gleplot.Axes.plot(), step(), stem(), errorbar(), hist(), the function and file series) takes instead when the call passes no color. Any spelling gleplot.colors.rgb_to_gle() accepts. Default: None, which uses each axes’ colour cycle, as matplotlib does (see the Notes).

Type:

str or None

default_marker_color

Same, for a marker-only series – what gleplot.Axes.scatter() produces, and plot() with a marker and no line. Default: None, the colour cycle.

Type:

str or None

line_style_solid

GLE line style for solid lines. Default: 1

Type:

int

line_style_dashed

GLE line style for dashed lines (–). Default: 3

Type:

int

line_style_dotted

GLE line style for dotted lines (:). Default: 2

Type:

int

line_style_dashdot

GLE line style for dash-dot lines (-.). Default: 6

Type:

int

line_cap

How every line in the figure ends (GLE set cap). 'square' is matplotlib’s 'projecting'. None (the default) writes nothing and leaves GLE’s own butt.

Type:

{‘butt’, ‘round’, ‘square’} or None

line_join

How every line in the figure turns a corner (GLE set join). 'mitre' is matplotlib’s 'miter'. None (the default) writes nothing and leaves GLE’s own mitre.

Type:

{‘mitre’, ‘round’, ‘bevel’} or None

dashlen

Length in cm of the shortest dash in every line style (GLE set dashlen). The lstyle digits are multiples of it, so a larger value stretches dashes and gaps alike. GLE does not scale dashes with the line width, so a thick dashed line can read as dotted; raise dashlen to open it up. None (the default) writes nothing and leaves GLE’s own 0.04 cm.

Type:

float or None

usetex

Typeset every label with LaTeX (GLE set texlabels 1), as matplotlib’s text.usetex does: titles, axis labels, tick labels, legend entries and text annotations. Strings reach LaTeX as written, so $...$ is LaTeX math rather than gleplot’s mathtext translation, and text outside it must be valid LaTeX (\_ for an underscore). Labels already set keep their GLE markup, so set this when creating the figure. Compiling needs a LaTeX installation; SVG output is not available. Default: False

Type:

bool

Notes

With default_color and default_marker_color left at None, a series given no colour takes the next of matplotlib’s 'C0' to 'C9', per axes, exactly where matplotlib would: plot(), step(), errorbar(), hist() (one colour per data set) and stackplot() (one per layer) advance the line cycle; scatter(), bar(), barh(), fill(), fill_between() and fill_betweenx() advance a separate patch cycle; stem(), hlines() and vlines() draw in 'C0' without advancing either. An axes made by twinx/twiny has cycles of its own.

A default_linewidth, default_color or default_marker_color other than its default is recorded in a saved file’s metadata, so a figure opened with gleplot.open_gle() gives new series the same defaults. A colour is recorded as the GLE colour it draws. A figure opened that way continues each cycle after the series whose colours follow it.

The line_style_* defaults are the GLE lstyle numbers that actually render as their names say, measured by compiling a ruler of set lstyle 1..9 strokes with GLE 4.3.10 and looking at the result:

lstyle

renders as

1

solid

2

dotted (dense)

3

dashed

4

dotted (sparse)

5

dashed (long)

6

dash-dot

7

dash-dot (sparse)

8

dash-dot (dense)

9

dashed (long, sparse)

Any GLE lstyle code is accepted, not only 1-9. GLE reads a code of more than one digit as alternating run lengths, black then white: 42 is a dash four units long followed by a gap two units long.

gleplot previously defaulted to dashed=2 / dotted=3 / dashdot=4, i.e. linestyle='--' drew a dotted line and ':' drew a dashed one. Do not “restore” those numbers: they were transposed, and dashed-vs-dotted is load-bearing in publication figures where a dashed curve conventionally means a fit.

to_dict()[source]

Convert config to dictionary.

Return type:

Dict[str, Any]

GLEGraphConfig

class gleplot.GLEGraphConfig(scale_mode='auto', title_distance=None, xlabel_distance=None, ylabel_distance=None, legend_position='tr', legend_offset_x=0.0, legend_offset_y=0.0, smooth_curves=False, show_grid=False, default_cmap='viridis', colormap_pixels=200)[source]

GLE graph configuration.

Parameters:
  • scale_mode (str)

  • title_distance (float | None)

  • xlabel_distance (float | None)

  • ylabel_distance (float | None)

  • legend_position (str)

  • legend_offset_x (float)

  • legend_offset_y (float)

  • smooth_curves (bool)

  • show_grid (bool)

  • default_cmap (str)

  • colormap_pixels (int)

scale_mode

Who sizes the graph. ‘auto’ (the default): gleplot places each axes frame from its subplot cell or add_axes rect, with margins for labels. ‘fullsize’: a figure with a single axes, other than one made with add_axes, is written with GLE’s fullsize, filling the page with no margins; figures with several axes keep gleplot’s layout. ‘fixed’: no effect, and warns; the figure is written as under ‘auto’. Any other value raises ValueError.

Type:

str

title_distance

Figure-wide default for Axes.title_dist – the dist option of GLE’s title command, in cm. A per-axes title_dist wins over it. None (the default) emits no dist at all, leaving GLE’s own spacing.

Changed in version 2.4: Was an inert 0.1 that nothing read. It is now the default for the per-axes distance, and its default is None so that figures which never set it emit exactly the GLE they always did. A project serialized with the old inert 0.1 will, once reloaded, actually emit dist 0.1.

Type:

float or None

xlabel_distance

Same, for Axes.xlabel_dist – the dist option of GLE’s xtitle command (distance between the axis title and the tick labels), in cm. Default: None.

Type:

float or None

ylabel_distance

Same, for Axes.ylabel_dist (GLE ytitle ... dist) and, when the axes sets no distance of its own, Axes.y2label_dist (y2title ... dist). Default: None.

Type:

float or None

legend_position

Default legend position: ‘tl’, ‘tr’, ‘bl’, ‘br’, ‘tc’, ‘bc’, ‘lc’, ‘rc’, ‘cc’. Options: ‘top right’, ‘top left’, ‘bottom right’, ‘bottom left’, ‘center’. Default: ‘tr’ (top right)

Type:

str

legend_offset_x

Figure-wide default legend x-offset from its anchor (cm), used by every axes whose own legend_offset is None. Default: 0.0.

Type:

float

legend_offset_y

The y half of the same default (cm). Default: 0.0.

(0.0, 0.0) means “no offset”, and emits no offset clause – so the defaults leave GLE output unchanged.

Type:

float

smooth_curves

Draw line series as a fitted spline through the points (GLE’s smooth keyword) instead of as a polyline joining them. Opt-in: a smoothed curve is an interpolation, not the data, so it must never be applied without being asked for. Applies to plot(), line_from_file() and the line drawn by errorbar(). Fills, contour lines, step, stem and histogram lines, and a plot line broken by NaN (which warns) are never smoothed. Default: False

Type:

bool

show_grid

Figure-wide default grid: when True, every axes that has not called gleplot.Axes.grid() itself gets a main-tick grid on both axes (GLE xaxis grid / yaxis grid). An axes that HAS called grid() – including grid(False) – keeps its own answer. Default: False

Type:

bool

default_cmap

Default colour map used by imshow/tripcolor when cmap is not passed. One of the names in gleplot.palettes.SUPPORTED_CMAPS, or one with _r appended for its reversed form. Default: ‘viridis’

Type:

str

colormap_pixels

Default bitmap resolution (pixels per side) for colormap rendering when imshow(pixels=...) is not given. Default: 200

Type:

int

to_dict()[source]

Convert config to dictionary.

Return type:

Dict[str, Any]

GLEMarkerConfig

class gleplot.GLEMarkerConfig(default_marker='fcircle', msize_scale=1.0, mdist=None)[source]

Marker style configuration.

Parameters:
default_marker

Default marker type when creating scatter plots. Options: ‘circle’, ‘square’, ‘triangle’, ‘diamond’, ‘cross’, ‘fcircle’, ‘fsquare’, ‘ftriangle’, ‘fdiamond’ (filled variants). Default: ‘fcircle’ (filled circle)

Type:

str

msize_scale

Scaling factor for marker sizes. Multiplies the msize value. Default: 1.0

Type:

float

mdist

Default marker distance in cm along a line that has markers: GLE’s mdist, written on each marked line that does not pass its own mdist to plot. If None, markers appear at every point. Default: None

Type:

Optional[float]

to_dict()[source]

Convert config to dictionary.

Return type:

Dict[str, Any]

GlobalConfig

class gleplot.GlobalConfig[source]

Global gleplot configuration.

Provides singleton-like access to default configuration settings that apply to all new figures created.

Access style, graph, and marker configurations directly as class attributes:

Examples

>>> from gleplot.config import GlobalConfig
>>> # Change default font globally
>>> GlobalConfig.style.font = 'texcmss'  # TeX Computer Modern Sans Serif
>>> # All new figures will use this font
>>> # Or reset to defaults
>>> GlobalConfig.reset()

Notes

Copy-at-construction, not shared-by-reference. GlobalConfig.style (and .graph, .marker) really is one shared, mutable instance – editing it here, before any figure exists, is exactly how you change the default for every figure created afterwards. But gleplot.figure.Figure and gleplot.writer.GLEWriter each take an independent COPY of the current value at construction time (when their own style/ graph/marker argument is omitted), not a reference to this singleton. So:

  • GlobalConfig.style.font = 'x' then fig = Figure() – fig gets 'x' (the default was read at construction time).

  • fig = Figure() then fig.style.font = 'x' – only fig changes; GlobalConfig.style.font and every other figure are unaffected. Before this was fixed, this in-place edit silently mutated GlobalConfig.style itself (since fig.style and GlobalConfig.style were the same object), leaking into every figure created afterwards in the process.

classmethod reset()[source]

Reset all configurations to defaults.

classmethod get_style()[source]

Get global style configuration.

Return type:

GLEStyleConfig

classmethod get_graph()[source]

Get global graph configuration.

Return type:

GLEGraphConfig

classmethod get_marker()[source]

Get global marker configuration.

Return type:

GLEMarkerConfig

classmethod to_dict()[source]

Export all configurations as dictionary.

Return type:

Dict[str, Dict[str, Any]]