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
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
- default_linewidth
Default line width in points (unit: 1/72 inch). Default: 1.5 points ≈ 0.053 cm (increased for visibility in PDFs)
- Type:
- 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 nocolor. Any spellinggleplot.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, andplot()with a marker and no line. Default: None, the colour cycle.- Type:
str or None
- 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 ownbutt.- 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 ownmitre.- Type:
{‘mitre’, ‘round’, ‘bevel’} or None
- dashlen
Length in cm of the shortest dash in every line style (GLE
set dashlen). Thelstyledigits 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; raisedashlento 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’stext.usetexdoes: 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:
Notes
With
default_coloranddefault_marker_colorleft 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) andstackplot()(one per layer) advance the line cycle;scatter(),bar(),barh(),fill(),fill_between()andfill_betweenx()advance a separate patch cycle;stem(),hlines()andvlines()draw in'C0'without advancing either. An axes made bytwinx/twinyhas cycles of its own.A
default_linewidth,default_colorordefault_marker_colorother than its default is recorded in a saved file’s metadata, so a figure opened withgleplot.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 GLElstylenumbers that actually render as their names say, measured by compiling a ruler ofset lstyle 1..9strokes with GLE 4.3.10 and looking at the result:lstylerenders 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
lstylecode is accepted, not only 1-9. GLE reads a code of more than one digit as alternating run lengths, black then white:42is 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.
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
Who sizes the graph. ‘auto’ (the default): gleplot places each axes frame from its subplot cell or
add_axesrect, with margins for labels. ‘fullsize’: a figure with a single axes, other than one made withadd_axes, is written with GLE’sfullsize, 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 raisesValueError.- Type:
- title_distance
Figure-wide default for
Axes.title_dist– thedistoption of GLE’stitlecommand, in cm. A per-axestitle_distwins over it.None(the default) emits nodistat all, leaving GLE’s own spacing.Changed in version 2.4: Was an inert
0.1that nothing read. It is now the default for the per-axes distance, and its default isNoneso that figures which never set it emit exactly the GLE they always did. A project serialized with the old inert0.1will, once reloaded, actually emitdist 0.1.- Type:
float or None
- xlabel_distance
Same, for
Axes.xlabel_dist– thedistoption of GLE’sxtitlecommand (distance between the axis title and the tick labels), in cm. Default: None.- Type:
float or None
- ylabel_distance
Same, for
Axes.ylabel_dist(GLEytitle ... 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:
- legend_offset_x
Figure-wide default legend x-offset from its anchor (cm), used by every axes whose own
legend_offsetis None. Default: 0.0.- Type:
- legend_offset_y
The y half of the same default (cm). Default: 0.0.
(0.0, 0.0)means “no offset”, and emits nooffsetclause – so the defaults leave GLE output unchanged.- Type:
- smooth_curves
Draw line series as a fitted spline through the points (GLE’s
smoothkeyword) 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 toplot(),line_from_file()and the line drawn byerrorbar(). Fills, contour lines, step, stem and histogram lines, and aplotline broken by NaN (which warns) are never smoothed. Default: False- Type:
- 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 (GLExaxis grid/yaxis grid). An axes that HAS calledgrid()– includinggrid(False)– keeps its own answer. Default: False- Type:
- default_cmap
Default colour map used by
imshow/tripcolorwhencmapis not passed. One of the names ingleplot.palettes.SUPPORTED_CMAPS, or one with_rappended for its reversed form. Default: ‘viridis’- Type:
- colormap_pixels
Default bitmap resolution (pixels per side) for
colormaprendering whenimshow(pixels=...)is not given. Default: 200- Type:
GLEMarkerConfig
- class gleplot.GLEMarkerConfig(default_marker='fcircle', msize_scale=1.0, mdist=None)[source]
Marker style configuration.
- 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:
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. Butgleplot.figure.Figureandgleplot.writer.GLEWritereach take an independent COPY of the current value at construction time (when their ownstyle/graph/markerargument is omitted), not a reference to this singleton. So:GlobalConfig.style.font = 'x'thenfig = Figure()–figgets'x'(the default was read at construction time).fig = Figure()thenfig.style.font = 'x'– onlyfigchanges;GlobalConfig.style.fontand every other figure are unaffected. Before this was fixed, this in-place edit silently mutatedGlobalConfig.styleitself (sincefig.styleandGlobalConfig.stylewere the same object), leaking into every figure created afterwards in the process.