API Reference (Plot)¶
sciwork.plot.Plot(figsize=(9, 6))
¶
Bases: Decor, Drawing, Layout, Ticks
Featureful Matplotlib figure manager with SciWork integrations.
Source code in src/sciwork/plot/base.py
52 53 54 55 56 | |
__slots__ = ()
class-attribute
instance-attribute
¶
Base¶
sciwork.plot.base.BasePlot(figsize=(9, 6))
¶
Provide figure lifecycle management and shared helpers.
Source code in src/sciwork/plot/base.py
52 53 54 55 56 | |
_limits = _DataLimits.empty()
instance-attribute
¶
figsize = figsize
instance-attribute
¶
_axes_or_default(ax)
¶
Return ax when provided or fall back to the default axes.
Source code in src/sciwork/plot/base.py
59 60 61 62 63 64 65 | |
_get_axis_limits(axis)
¶
Return cached (min, max) values for axis.
Source code in src/sciwork/plot/base.py
79 80 81 82 | |
_iter_axes(selector)
staticmethod
¶
Yield axis names that match selector.
Source code in src/sciwork/plot/base.py
84 85 86 87 88 89 90 91 | |
_update_limits(x, y=None, z=None)
¶
Store min/max boundaries for any axis that receives data.
Source code in src/sciwork/plot/base.py
67 68 69 70 71 72 73 74 75 76 77 | |
add_inset(main_ax, *, left, bottom, width, height)
staticmethod
¶
Create inset axes anchored to main_ax.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
main_ax
|
'Axes'
|
The parent axes that will host the inset axes. |
required |
left
|
float
|
Relative coordinate in a figure fraction. |
required |
bottom
|
float
|
Relative coordinate in a figure fraction. |
required |
width
|
float
|
Relative coordinate in a figure fraction. |
required |
height
|
float
|
Relative coordinate in a figure fraction. |
required |
Returns:
| Type | Description |
|---|---|
'Axes'
|
Newly created inset axes. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If any dimension is negative or exceeds the figure bounds. |
Source code in src/sciwork/plot/base.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | |
create_grid_layout(nrows, ncols)
¶
Create a grid of subplots sized to the instance default.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
nrows
|
int
|
Number of rows in the grid. |
required |
ncols
|
int
|
Number of columns in the grid. |
required |
Returns:
| Type | Description |
|---|---|
Tuple['Figure', Sequence[Sequence['Axes']]]
|
The generated Matplotlib figure and an array-like structure of axes objects for further customization. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/sciwork/plot/base.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | |
save_plot(filename, *, dpi=300, fig_format='.png')
¶
Persist the current figure to disk and return the solved path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Base filename or path where the figure should be stored. The file extension is inferred from |
required |
dpi
|
int
|
Rendering resolution in dots per inch. |
300
|
fig_format
|
str
|
Output format passed to :meth: |
'.png'
|
Returns:
| Type | Description |
|---|---|
str
|
The filename with the ensured extension. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/sciwork/plot/base.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | |
show_plot()
staticmethod
¶
Display the figure using tight layout adjustments.
The method applies :func:matplotlib.pyplot.tight_layout before
calling :func:matplotlib.pyplot.show to reduce superfluous margins.
Source code in src/sciwork/plot/base.py
137 138 139 140 141 142 143 144 145 146 | |
Drawing¶
sciwork.plot.drawing.Drawing(figsize=(9, 6))
¶
Bases: BasePlot
Collection of drawing primitives used by :class:~sciwork.plot.Plot.
Source code in src/sciwork/plot/base.py
52 53 54 55 56 | |
draw_horizontal_line(y, *, color='black', linewidth=2.0, linestyle='-', label=None, alpha=1.0, ax=None)
¶
Add a horizontal line across the axes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
y
|
float
|
Y coordinate where the line should be drawn. |
required |
color
|
str
|
Color styling parameter. |
'black'
|
linewidth
|
float
|
Line width styling parameter. |
2.0
|
linestyle
|
str
|
Line style styling parameter. |
'-'
|
label
|
Optional[str]
|
Optional line label. |
None
|
alpha
|
float
|
Opacity of the line. |
1.0
|
ax
|
Optional['Axes']
|
Axes to draw on. Defaults to the primary axes. |
None
|
Returns:
| Type | Description |
|---|---|
'Axes'
|
The axes that contain the new line. |
Source code in src/sciwork/plot/drawing.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | |
draw_vertical_line(x, *, color='black', linewidth=2.0, linestyle='-', label=None, alpha=1.0, ax=None)
¶
Add a vertical line across the axes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
X coordinate for the line. |
required |
color
|
str
|
Color styling parameter. |
'black'
|
linewidth
|
float
|
Line width styling parameter. |
2.0
|
linestyle
|
str
|
Line style styling parameter. |
'-'
|
label
|
Optional[str]
|
Optional line label. |
None
|
alpha
|
float
|
Opacity of the line. |
1.0
|
ax
|
Optional['Axes']
|
Axes to draw on. Defaults to the primary axes. |
None
|
Returns:
| Type | Description |
|---|---|
'Axes'
|
The axes that contain the new line. |
Source code in src/sciwork/plot/drawing.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
plot_1d(data, *, ax=None)
¶
Plot a simple 1D series against its index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Sequence[float]
|
Iterable of numeric values. |
required |
ax
|
Optional['Axes']
|
Axes to draw on. Defaults to the primary axes. |
None
|
Returns:
| Type | Description |
|---|---|
'Axes'
|
The axes that contain the line plot. |
Source code in src/sciwork/plot/drawing.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 | |
plot_2d(x, y, *, plot_type='line', ax=None, color=None, alpha=1.0, label=None, linewidth=2.0, linestyle='-', markersize=20.0, markertype='o', ma_window=5, ma_iterations=1, bar_width=0.8, edgecolor=None, zorder=None)
¶
Render diverse 2D visualizations (line, scatter, moving average, histogram, bar).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Sequence[float]
|
X-coordinates of the observations. |
required |
y
|
Sequence[float]
|
Y-coordinates of the observations. Must be provided for all built-in plot types. |
required |
plot_type
|
PlotKind
|
One of |
'line'
|
ax
|
Optional['Axes']
|
Axes to draw on. Defaults to the primary axes. |
None
|
color
|
Optional[str]
|
Color of the data visualization. |
None
|
alpha
|
float
|
Opacity of the data visualization. |
1.0
|
label
|
Optional[str]
|
Label for the legend. |
None
|
linewidth
|
float
|
Line width of the data visualization. Applies to |
2.0
|
linestyle
|
str
|
Line style of the data visualization. Applies to |
'-'
|
markersize
|
float
|
Size of the markers in |
20.0
|
markertype
|
str
|
Type of the markers in |
'o'
|
ma_window
|
int
|
Size of the moving window used in the |
5
|
ma_iterations
|
int
|
Iteration count for the |
1
|
bar_width
|
float
|
Width of the bars in |
0.8
|
edgecolor
|
Optional[str]
|
Edge color of the bars in |
None
|
zorder
|
Optional[int]
|
Z-order of the visualization (rendering order). |
None
|
Returns:
| Type | Description |
|---|---|
'Axes'
|
The axes that contain the visualization. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If required data is missing, or |
Source code in src/sciwork/plot/drawing.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | |
plot_3d(x, y, z, *, ax=None)
¶
Create a 3D scatter plot (creates 3D axes if necessary).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Sequence[float]
|
X-coordinates of the observations. |
required |
y
|
Sequence[float]
|
Y-coordinates of the observations. |
required |
z
|
Sequence[float]
|
Z-coordinates of the observations. |
required |
ax
|
Optional['Axes']
|
Existing 3D axes. When |
None
|
Returns:
| Type | Description |
|---|---|
'Axes'
|
The 3D axes containing the scatter plot. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the coordinate sequences differ in length. |
Source code in src/sciwork/plot/drawing.py
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 | |
plot_std_deviation(x, y, yerr, *, color='gray', alpha=0.6, linewidth=2.0, ax=None)
¶
Plot error bars representing a standard deviation envelope.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Sequence[float]
|
X coordinates for the error bars. |
required |
y
|
Sequence[float]
|
Y coordinates for the error bars. |
required |
yerr
|
Sequence[float]
|
Symmetric deviations for each point; forwarded to :func: |
required |
color
|
str
|
Base color of the error bars. |
'gray'
|
alpha
|
float
|
Opacity of the error bars. |
0.6
|
linewidth
|
float
|
Thickness of the error lines. |
2.0
|
ax
|
Optional['Axes']
|
Axes to draw on. Defaults to the primary axes. |
None
|
Returns:
| Type | Description |
|---|---|
'Axes'
|
The axes that contain the error bars. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the input sequences differ in length. |
Source code in src/sciwork/plot/drawing.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | |
Layout¶
sciwork.plot.layout.Layout(figsize=(9, 6))
¶
Bases: BasePlot
Methods adjusting axis labels, limits, and spine positions.
Source code in src/sciwork/plot/base.py
52 53 54 55 56 | |
_set_spine_position(axes, spine, position)
staticmethod
¶
Position a spine against a data coordinate without type warnings.
Source code in src/sciwork/plot/layout.py
20 21 22 23 24 25 | |
set_axes_limits(*, ax=None, xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None)
¶
Set numeric boundaries for each axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ax
|
Optional['Axes']
|
Axes to update; defaults to the primary axes. |
None
|
xmin
|
Optional[Union[float, str]]
|
X-axis minimum. |
None
|
xmax
|
Optional[Union[float, str]]
|
X-axis maximum. |
None
|
ymin
|
Optional[Union[float, str]]
|
Y-axis minimum. |
None
|
ymax
|
Optional[Union[float, str]]
|
Y-axis maximum. |
None
|
zmin
|
Optional[Union[float, str]]
|
Z-axis minimum. |
None
|
zmax
|
Optional[Union[float, str]]
|
Z-axis maximum. |
None
|
Returns:
| Type | Description |
|---|---|
'Axes'
|
The axes with updated limits. |
Raises:
| Type | Description |
|---|---|
ValueError
|
When |
AttributeError
|
If z-axis limits are requested on a 2D axes. |
Source code in src/sciwork/plot/layout.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | |
set_axes_linewidth(linewidth=1.0, *, ax=None)
¶
Update the thickness of the axes' spines.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
linewidth
|
float
|
Width applied to the axes' spines. |
1.0
|
ax
|
Optional['Axes']
|
Target axes to modify, defaults to the primary axes. |
None
|
Returns:
| Type | Description |
|---|---|
'Axes'
|
The axes after linewidth updates. |
Source code in src/sciwork/plot/layout.py
106 107 108 109 110 111 112 113 114 115 116 117 118 | |
set_axis_label_size(size=12.0, *, axis='both', ax=None)
¶
Change the font size for one or more axis labels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
size
|
float
|
Font size to the selected labels. |
12.0
|
axis
|
AxisSelector
|
Selector describing which axes should change ("x", "y", "z", "both", or "all"). |
'both'
|
ax
|
Optional['Axes']
|
Axes to modify; defaults to the instance axes. |
None
|
Returns:
| Type | Description |
|---|---|
'Axes'
|
The axes with resized labels. |
Source code in src/sciwork/plot/layout.py
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | |
set_axis_position(*, axis='y', position=0.0, ax=None)
¶
Reposition a spine to a data coordinate on the opposing axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
axis
|
Literal['x', 'y']
|
Which axis to reposition ("x" or "y"). |
'y'
|
position
|
float
|
The coordinate on the opposite axis where the spine should cross. |
0.0
|
ax
|
Optional['Axes']
|
Axes to update. Defaults to the plot's primary axes. |
None
|
Returns:
| Type | Description |
|---|---|
'Axes'
|
The axes with updated spine placement. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/sciwork/plot/layout.py
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 | |
set_plot_labels(*, ax=None, title=None, xlabel=None, ylabel=None, zlabel=None, xshift=0.0, yshift=0.0, zshift=0.0, xt=0.0, yt=0.0)
¶
Assign axis labels to each axis and optionally shift their positions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ax
|
Optional['Axes']
|
Axes instance to modify. When |
None
|
title
|
Optional[str]
|
The plot title. |
None
|
xlabel
|
Optional[str]
|
X-label of the plot. |
None
|
ylabel
|
Optional[str]
|
Y-label of the plot. |
None
|
zlabel
|
Optional[str]
|
Z-label of the plot. |
None
|
xshift
|
float
|
Normalized horizontal shift of X-label. |
0.0
|
yshift
|
float
|
Normalized vertical shift of Y-label. |
0.0
|
zshift
|
float
|
Normalized shift along the Z-axis. |
0.0
|
xt
|
float
|
Additional vertical shift for X-label. |
0.0
|
yt
|
float
|
Additional horizontal shift for Y-label. |
0.0
|
Returns:
| Type | Description |
|---|---|
'Axes'
|
The axes that received the updates. |
Raises:
| Type | Description |
|---|---|
AttributeError
|
If |
Source code in src/sciwork/plot/layout.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
set_title_size(size=14.0, *, ax=None)
¶
Resize the title font.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
size
|
float
|
Target font size in points. |
14.0
|
ax
|
Optional['Axes']
|
Axes containing the title. Default to the primary axes. |
None
|
Returns:
| Type | Description |
|---|---|
'Axes'
|
The axes with updated title size. |
Source code in src/sciwork/plot/layout.py
178 179 180 181 182 183 184 185 186 187 188 189 190 | |
toggle_dark_mode(dark_mode=True, *, ax=None)
¶
Switch between light and dark color schemes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dark_mode
|
bool
|
When `True`` enable a dark background with light foreground colors; otherwise revert to light mode. |
True
|
ax
|
Optional['Axes']
|
Axes to update; defaults to the primary axes. |
None
|
Returns:
| Type | Description |
|---|---|
'Axes'
|
The axes after color adjustments. |
Source code in src/sciwork/plot/layout.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
Decor¶
sciwork.plot.decor.Decor(figsize=(9, 6))
¶
Bases: BasePlot
Helpers for grid lines, legends, and textual annotations.
Source code in src/sciwork/plot/base.py
52 53 54 55 56 | |
custom_text(text, *, position='upper right', fontcolor='black', fontsize=10.0, style=None, ha='center', va='center', ax=None)
¶
Insert arbitrary text in axes-relative coordinates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
String rendered inside the axes. |
required |
position
|
Union[str, Tuple[float, float]]
|
Named location or explicit |
'upper right'
|
fontcolor
|
str
|
Color of the text. |
'black'
|
fontsize
|
float
|
Text size in points. |
10.0
|
style
|
Optional[str]
|
Case-insensitive keywords such as |
None
|
ha
|
str
|
Horizontal alignment keyword passed to Matplotlib. |
'center'
|
va
|
str
|
Vertical alignment keyword passed to Matplotlib. |
'center'
|
ax
|
Optional['Axes']
|
Axes receiving the text. Defaults to the primary axes. |
None
|
Returns:
| Type | Description |
|---|---|
'Axes'
|
The axes containing the annotation. |
Source code in src/sciwork/plot/decor.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | |
set_grid(*, color='grey', alpha=0.5, which='both', linewidth=1.0, linestyle='--', axis='both', ax=None)
¶
Enable grid lines with custom styling.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
color
|
str
|
Grid line color. |
'grey'
|
alpha
|
float
|
Opacity applied to the grid lines. |
0.5
|
which
|
TickType
|
Whether to align grid lines with major ticks, minor ticks, or both. |
'both'
|
linewidth
|
float
|
Line width for the grid. |
1.0
|
linestyle
|
str
|
Matplotlib line style string such as |
'--'
|
axis
|
str
|
Select |
'both'
|
ax
|
Optional['Axes']
|
Axes to update; defaults to the primary axes. |
None
|
Returns:
| Type | Description |
|---|---|
'Axes'
|
The axes with the applied grid styling. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/sciwork/plot/decor.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
set_legend(*, position='best', alpha=1.0, fontsize=10.0, fontcolor='black', order=None, exclude_labels=None, ax=None)
¶
Display a legend with additional formatting controls.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
position
|
Union[str, Tuple[float, float]]
|
Legend location key or explicit axes-relative coordinates. |
'best'
|
alpha
|
float
|
Transparency of the legend background. |
1.0
|
fontsize
|
float
|
Size of the legend text. |
10.0
|
fontcolor
|
str
|
Color that is applied to each label. |
'black'
|
order
|
Optional[Sequence[int]]
|
Optional reordering indices for legend entries. |
None
|
exclude_labels
|
Optional[Sequence[str]]
|
Iterable of labels to omit from the legend. |
None
|
ax
|
Optional['Axes']
|
Axes to query for handles. Defaults to the primary axes. |
None
|
Returns:
| Type | Description |
|---|---|
Optional['Axes']
|
The axes when a legend is created, otherwise |
Source code in src/sciwork/plot/decor.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | |
Ticks¶
sciwork.plot.ticks.Ticks(figsize=(9, 6))
¶
Bases: BasePlot
Operations for tick appearance and axis scaling.
Source code in src/sciwork/plot/base.py
52 53 54 55 56 | |
reverse_axis(*, reverse_x=False, reverse_y=False, reverse_z=False, ax=None)
¶
Invert axis directions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reverse_x
|
bool
|
Flag to reverse the X axis. |
False
|
reverse_y
|
bool
|
Flag to reverse the Y axis. |
False
|
reverse_z
|
bool
|
Flag to reverse the Z axis. |
False
|
ax
|
Optional['Axes']
|
Axes to modify; defaults to the instance axes. |
None
|
Returns:
| Type | Description |
|---|---|
'Axes'
|
The axes with updated orientation. |
Source code in src/sciwork/plot/ticks.py
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | |
scale_axis_labels(scale_factor=None, *, method='simple', axis='x', is_log_scale=False, ax=None)
¶
Scale tick labels either by multiplication or orders of magnitude.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scale_factor
|
Optional[float]
|
Scaling factor. For |
None
|
method
|
Literal['simple', 'order']
|
Choose |
'simple'
|
axis
|
Axis
|
Axis whose labels should be modified. |
'x'
|
is_log_scale
|
bool
|
Set to |
False
|
ax
|
Optional['Axes']
|
Axes to modify; defaults to the instance axes. |
None
|
Returns:
| Type | Description |
|---|---|
'Axes'
|
The axes with scaled labels. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/sciwork/plot/ticks.py
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 | |
set_custom_tick_labels(tick_labels, *, axis='x', ax=None)
¶
Assign textual labels to currently visible ticks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tick_labels
|
Sequence[str]
|
Strings representing the replacement tick labels. |
required |
axis
|
Axis
|
Axis whose ticks should change. |
'x'
|
ax
|
Optional['Axes']
|
Axes to modify; defaults to the instance axes. |
None
|
Returns:
| Type | Description |
|---|---|
'Axes'
|
The axes with updated labels. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the number of labels does not match the visible tick count. |
Source code in src/sciwork/plot/ticks.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | |
set_custom_ticks(tick_values, *, axis='x', ax=None)
¶
Apply explicit tick positions for the given axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tick_values
|
Sequence[float]
|
Iterable of numeric positions for ticks. |
required |
axis
|
Axis
|
Axis that receives the ticks ( |
'x'
|
ax
|
Optional['Axes']
|
Axes to modify; defaults to the instance axes. |
None
|
Returns:
| Type | Description |
|---|---|
'Axes'
|
The axes with the custom tick positions. |
Source code in src/sciwork/plot/ticks.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
set_log_scale(*, log_x=False, log_y=False, log_z=False, ax=None)
¶
Switch axes to a logarithmic scale if requested.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log_x
|
bool
|
If |
False
|
log_y
|
bool
|
If |
False
|
log_z
|
bool
|
If |
False
|
ax
|
Optional['Axes']
|
Axes to modify; defaults to the instance axes. |
None
|
Returns:
| Type | Description |
|---|---|
'Axes'
|
The axes with updated scale configuration. |
Source code in src/sciwork/plot/ticks.py
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | |
set_minor_ticks(num_minor_ticks=1, *, axis='both', ax=None)
¶
Configure additional minor ticks for linear or logarithmic axes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_minor_ticks
|
int
|
Number of subdivisions between major ticks ( |
1
|
axis
|
AxisSelector
|
Selector that describes which axes to adjust. |
'both'
|
ax
|
Optional['Axes']
|
Axes to modify; defaults to the instance axes. |
None
|
Returns:
| Type | Description |
|---|---|
'Axes'
|
The axes with new minor locators. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/sciwork/plot/ticks.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
set_tick_invisible(*, axis='both', ax=None)
¶
Hide ticks and tick labels on the requested axes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
axis
|
AxisSelector
|
Selector describing which axes to hide. |
'both'
|
ax
|
Optional['Axes']
|
Axes to modify; defaults to the instance axes. |
None
|
Returns:
| Type | Description |
|---|---|
'Axes'
|
The axes with disabled ticks. |
Source code in src/sciwork/plot/ticks.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
set_tick_label_size(size=10.0, *, axis='both', ax=None)
¶
Resize tick label fonts, including offset text.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
size
|
float
|
Target font size in points. |
10.0
|
axis
|
AxisSelector
|
Selector that describes which axes to update. |
'both'
|
ax
|
Optional['Axes']
|
Axes to modify; defaults to the instance axes. |
None
|
Returns:
| Type | Description |
|---|---|
'Axes'
|
The axes with resized tick labels. |
Source code in src/sciwork/plot/ticks.py
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 | |
set_tick_length(length=4.0, *, tick_type='both', axis='both', ax=None)
¶
Update tick lengths for major and/or minor ticks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
length
|
float
|
Length in points assigned to the selected tick types. |
4.0
|
tick_type
|
TickType
|
Choose |
'both'
|
axis
|
AxisSelector
|
Selector describing the axes that should change. |
'both'
|
ax
|
Optional['Axes']
|
Axes to modify; defaults to the instance axes. |
None
|
Returns:
| Type | Description |
|---|---|
'Axes'
|
The axes after tick length updates. |
Source code in src/sciwork/plot/ticks.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |
set_ticks_linewidth(linewidth=1.0, *, axis='both', ax=None)
¶
Adjust tick line width on selected axes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
linewidth
|
float
|
Width applied to the ticks. |
1.0
|
axis
|
AxisSelector
|
Selector describing which axes to update ("x", "y", "z", "both", or "all"). |
'both'
|
ax
|
Optional['Axes']
|
Axes to modify; defaults to the instance axes. |
None
|
Returns:
| Type | Description |
|---|---|
'Axes'
|
The axes with updated tick widths. |
Source code in src/sciwork/plot/ticks.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | |