Skip to content

Latest commit

 

History

History
218 lines (166 loc) · 6.88 KB

lbd-plot.md

File metadata and controls

218 lines (166 loc) · 6.88 KB
search
boost
0.3

lbd.plot — figures in the viewer's styles

import lbd.plot as lp        # needs: pip install "lbd[plot]"

Every public name of lbd.plot, generated from the code. For a guided introduction, see Plotting from your code (Python); to find the right function for a task, see Which function do I need?. The style settings are listed in Style settings.

Choose a style

Every function below takes style=: a preset name, a .lbd.json file, a dict of settings, or a Style. These three are for looking at styles.

You want to… Use
see which preset names exist [list_styles][lbd.plot.list_styles]
get the full settings of a preset, file or dict (to read or change them) [load_style][lbd.plot.load_style]
know what you get when you pass no style [default_style][lbd.plot.default_style]
see what a style looks like, on a built-in sample figure [preview][lbd.plot.preview]

::: lbd.plot.list_styles options: heading_level: 3

::: lbd.plot.load_style options: heading_level: 3

::: lbd.plot.default_style options: heading_level: 3

::: lbd.plot.preview options: heading_level: 3

Style your own figures

For figures you draw with matplotlib yourself.

You want to… Use
style the figures made in one block of code [use][lbd.plot.use] (with lp.use("thesis"): ...)
style every figure of a notebook or script [activate][lbd.plot.activate]
a figure of another size, or a grid of panels [subplots][lbd.plot.subplots]
restyle a figure made elsewhere [apply][lbd.plot.apply]
save outside the with block, exactly like the viewer exports [save][lbd.plot.save]

::: lbd.plot.use options: heading_level: 3

::: lbd.plot.activate options: heading_level: 3

::: lbd.plot.subplots options: heading_level: 3

::: lbd.plot.apply options: heading_level: 3

::: lbd.plot.save options: heading_level: 3

Units and labels

You want to… Use
readable numbers: 7e9 Hz → 7 GHz, or a prefix you choose [prefix][lbd.plot.prefix]
an axis title with its unit, in the style's format [axis_label][lbd.plot.axis_label]

::: lbd.plot.prefix options: heading_level: 3

::: lbd.plot.axis_label options: heading_level: 3

Plot data like the viewer

You have… Use
an lbd.Dataset or an .lbd file [plot][lbd.plot.plot]
plain arrays [quick][lbd.plot.quick]
the right-hand axis plot drew (curves of two units) [right_axis][lbd.plot.right_axis]

::: lbd.plot.plot options: heading_level: 3

::: lbd.plot.quick options: heading_level: 3

::: lbd.plot.right_axis options: heading_level: 3

The numbers a plot shows

You want… Use
what a curve plot or heat map shows, as a table or CSV file [table][lbd.plot.table], then [Table.to_csv][lbd.plot.Table.to_csv]
all of a file's values, any number of axes, as CSV [groups][lbd.plot.groups], then [table][lbd.plot.table] with group=

::: lbd.plot.table options: heading_level: 3

::: lbd.plot.groups options: heading_level: 3

::: lbd.plot.Table options: heading_level: 3 members: [to_csv, estimate, columns, header_lines, check_matrix, ragged]

::: lbd.plot.Column options: heading_level: 3

::: lbd.plot.Group options: heading_level: 3

Manage presets

Only needed to create, change or delete presets from code, or to reproduce the viewer's exact style for a file. For plotting, pass the preset's name as style=.

You want to… Use
create or change a preset [PresetStore.save][lbd.plot.PresetStore.save]
add a .lbd.json file as a preset [PresetStore.import_file][lbd.plot.PresetStore.import_file]
remove a preset, or reset a built-in one [PresetStore.delete][lbd.plot.PresetStore.delete]
see what a preset changes (only the differences) [PresetStore.preset][lbd.plot.PresetStore.preset]
settings a newer LBD wrote into a preset (kept unchanged) [PresetStore.kept][lbd.plot.PresetStore.kept]
a preset with a file's own changes on top (a file without a saved style) [PresetStore.resolve][lbd.plot.PresetStore.resolve]
rename a preset (its old names remembered) [PresetStore.rename][lbd.plot.PresetStore.rename]
presets made by an older LBD (not read: delete or make again) [PresetStore.older_names][lbd.plot.PresetStore.older_names], [PresetStore.is_older][lbd.plot.PresetStore.is_older]
how a file's saved style differs from the preset here [style_differences][lbd.plot.style_differences]
save a preset into files whole, after changing it [restyle][lbd.plot.restyle]

::: lbd.plot.PresetStore options: heading_level: 3 members: [names, is_builtin, is_customized, older_names, is_older, preset, kept, style, save, version, rename, renamed_from, delete, import_file, resolve]

::: lbd.plot.style_differences options: heading_level: 3

::: lbd.plot.restyle options: heading_level: 3

::: lbd.plot.config_dir options: heading_level: 3

Constants

Name What it is
lp.KINDS The plot types plot draws: "auto", "curve", "heatmap", "matrix", "bars", "bars3d", "histogram", "scatter" (Plot settings).
lp.COMPLEX_MODES What complex= takes for complex data: "abs", "db", "phase", "phase_deg", "phase_unwrap", "phase_deg_unwrap", "real", "imag", "iq".
lp.PREFIXES The unit prefixes prefix uses, by letter, with their power of ten ("G": 9, "µ": -6, …): Unit prefixes.
lp.BUILTIN_PRESETS The presets LBD comes with, by name, with their description ("default").
lp.STYLE_SUFFIX The ending of a style file, ".lbd.json".

Errors and warnings

Errors stop the call: something can't be done as asked. Both are ValueErrors.

Warnings mean the call worked, but something was ignored or adjusted; read them, they usually point at a typo or a setting that doesn't apply. All are lbd.LBDWarnings. To silence one kind on purpose:

import warnings
import lbd.plot as lp

warnings.filterwarnings("ignore", category=lp.UnitWarning)   # or lp.RenderWarning, lbd.LBDWarning, ...

::: lbd.plot.StyleError options: heading_level: 3

::: lbd.plot.RenderError options: heading_level: 3

::: lbd.plot.StyleWarning options: heading_level: 3

::: lbd.plot.RenderWarning options: heading_level: 3

::: lbd.plot.UnitWarning options: heading_level: 3