File-Based Series
gleplot can reference columns in an existing data file instead of generating new sidecar .dat files for every plot element.
This is useful when your data already exists in analysis outputs or experiment logs.
Supported Methods
Axes.errorbar_from_file(data_file, x_col, y_col, yerr_col=None, ...)Axes.line_from_file(data_file, x_col, y_col, ...)
Column indices are 1-based to match GLE conventions.
Minimal Example
import gleplot as glp
fig = glp.figure(figsize=(8, 5))
ax = fig.add_subplot(111)
ax.errorbar_from_file('results.dat', x_col=1, y_col=2, yerr_col=3, label='Measured')
ax.line_from_file('results.dat', x_col=1, y_col=4, linestyle='--', label='Model')
ax.legend()
fig.savefig('from_file.gle')
Expected Data Format
Any whitespace-delimited file that GLE can read, for example:
! c1=time c2=signal c3=signal_err c4=model
0.0 1.20 0.08 1.17
0.5 1.33 0.09 1.31
1.0 1.41 0.10 1.39
Reading Options
skiprows, comment and max_rows tell GLE how to read the file: skip
leading lines, use another comment marker than !, and stop after a number
of data rows. They become GLE’s ignore, comment and numrows options on
the data command; the API reference for
Axes.line_from_file
gives the details.
ax.line_from_file(
'log.csv', x_col=1, y_col=2, skiprows=3, comment='#', max_rows=100
)
GLE also reads these files on its own terms, with no keyword needed:
If the first row holds labels rather than numbers, GLE uses the label of each series’ y column as its legend entry when the call gives no
label.x_col=0uses the row number (1, 2, 3, …) as x. If the file’s first column is text, GLE then labels the x axis with it, which plots one value per category.A file name ending in
.gzis read as gzip-compressed data.
Typical Workflow
Produce
results.datin your analysis step.Build figures that reference file columns.
Save
.glescripts without generating extra measurement sidecars.Re-run plots against updated data files without changing plotting code.
Notes
A file name holding a double quote raises
ValueErrorat the call, as GLE cannot load it. A name with spaces is fine.Keep a clear column map in comments at the top of data files.
Use consistent units per column.
For mixed workflows, you can combine generated series (
plot,scatter) and file-backed series in the same axes.For working examples, see:
examples/advanced/errorbar_from_file.pyexamples/advanced/line_from_file.py