visualdynamics.plot.log_axis¶
log_axis
¶
Log-axis tick labels that fit the axis they are drawn on.
pyqtgraph's log axis labels every tick from 1 to 9 in each decade when the axis spans few decades, and the first level of tick text is always drawn, however little room there is: two decades on a plot 100 pixels tall carried eighteen labels on top of each other. It also scales a log axis by an SI prefix, so a spectrum in N·s read '10¹' for 1e-5 beside a '×1e-06' on the axis label.
Here the labels are the densest set that fits: every mantissa, then 1, 2 and 5, then 1 and 3, then the decades alone, then every second, fifth or tenth decade. The room a label needs is measured from the axis font: a line's height on a vertical axis, the widest label's width on a horizontal one. Every tick from 1 to 9 is still drawn, unlabeled, while there are pixels for it, so the grid reads as a log grid. A span too narrow to hold two of those labels (less than a factor of two, say) is labeled at round values in between instead. A log axis takes no SI prefix: its labels carry their own powers of ten.
This applies to every axis in the process. The package makes its plots
in more than thirty places, each through pyqtgraph's default axis, and
how a log axis is labeled is a property of the axis, not of a plot, so
the three methods are replaced on pyqtgraph.AxisItem itself when the
plotting package is imported (install).
Functions:
| Name | Description |
|---|---|
label |
A log axis's text for |
choose |
The mantissas to label and every how many decades, for a log |
log_tick_values |
Replaces |
log_tick_strings |
Replaces |
update_auto_si_prefix |
Replaces |
install |
Put these on |
Functions:¶
label
¶
A log axis's text for value: plain digits from 0.01 up to
10 000 ('0.5', '200'), powers of ten outside ('2·10⁻⁵', '10⁶').
Source code in src/visualdynamics/plot/log_axis.py
choose
¶
The mantissas to label and every how many decades, for a log
span from low to high (log10 values) drawn over pixels, each
label needing room pixels from the next.
Source code in src/visualdynamics/plot/log_axis.py
log_tick_values
¶
Replaces AxisItem.logTickValues: the labeled ticks first, the
rest unlabeled after them.
Source code in src/visualdynamics/plot/log_axis.py
log_tick_strings
¶
log_tick_strings(axis: AxisItem, values: Sequence[float], scale: float, spacing: float) -> list[str]
Replaces AxisItem.logTickStrings: the text of the labeled ticks,
nothing for the rest.
Source code in src/visualdynamics/plot/log_axis.py
update_auto_si_prefix
¶
Replaces AxisItem.updateAutoSIPrefix: no prefix on a log axis,
whose labels carry their own powers of ten.
Source code in src/visualdynamics/plot/log_axis.py
install
¶
Put these on pyqtgraph.AxisItem, for every axis in the process.