4.1.1.2.1.2. lib.plotting.style
#
4.1.1.2.1.2.1. Module Contents#
4.1.1.2.1.2.1.1. Classes#
Class for managing plot styles and settings. |
|
4.1.1.2.1.2.1.2. Functions#
4.1.1.2.1.2.1.3. Data#
4.1.1.2.1.2.1.4. API#
- lib.plotting.style.script_name = 'basename(...)'#
- lib.plotting.style.figsize(scale, nplots=1)#
- lib.plotting.style.pgf_with_latex = None#
- class lib.plotting.style.Style(style='nature', color_scheme='default')#
Class for managing plot styles and settings.
- Parameters:
style (str) – Style name, default is ‘nature’.
color_scheme (str) – Color scheme name, default is ‘default’.
Initialization
Initialize the Style object with the specified style and color scheme.
- Parameters:
style (str) – Style name.
color_scheme (str) – Color scheme name.
- set_style(style, color_scheme)#
Set the plot style and color scheme.
- Parameters:
style (str) – Style name.
color_scheme (str) – Color scheme name.
- update()#
Allow updating rcparams or colors.
- get_figsize(scale=1.0, cols=1, rows=1, ratio=np.sqrt(5.0) - 1.0 / 2.0)#
Calculate figure size based on scale, columns, rows, and ratio.
- Parameters:
scale (float) – Scale factor for figure size, default is 1.
cols (int) – Number of columns, default is 1.
rows (int) – Number of rows, default is 1.
ratio (float) – Aesthetic ratio set to the golden mean, default is (np.sqrt(5.0) - 1.0) / 2.0.
- Returns:
Figure size [width, height].
- Return type:
list
- handle_ticks(axis, nx=3, ny=3)#
Handle ticks for the given axis.
- Parameters:
axis (object) – Axis object.
nx (int) – Number of ticks for x-axis, default is 3.
ny (int) – Number of ticks for y-axis, default is 3.
- despine_axes(axes=[], end_ticks=False)#
Remove spines from the specified axes and optionally disable ticks at the ends.
- Parameters:
axes (list) – List of axes objects to despine, default is an empty list.
end_ticks (bool) – Whether to disable ticks at the ends, default is False.
- drop_axes(axes=[], dirs=['left', 'right', 'bottom', 'top'])#
Move spines outward by a specified distance for the specified axes.
- Parameters:
axes (list) – List of axes objects to drop spines, default is an empty list.
dirs (list) – List of directions to drop spines, default is [‘left’, ‘right’, ‘bottom’, ‘top’].
- hide_axes(axes=[], dirs=['left', 'right', 'bottom', 'top'])#
Hide spines and ticks for the specified axes.
- Parameters:
axes (list) – List of axes objects to hide spines and ticks, default is an empty list.
dirs (list) – List of directions to hide spines and ticks, default is [‘left’, ‘right’, ‘bottom’, ‘top’].
- _set_rcparams(style)#
Set matplotlib rcParams based on the specified style.
- Parameters:
style (str) – Style name.
- _define_color_scheme(color_scheme=None)#
Define the color scheme for the plot.
- Parameters:
color_scheme (str, optional) – Name of the color scheme to use, default is None.
- _generate_lighter_shades(color, num_shades=1, brightness_factor=1.2)#
Generate lighter shades of a given color.
- Parameters:
color (str or tuple) – The color for which lighter shades are generated.
num_shades (int, optional) – Number of lighter shades to generate, default is 1.
brightness_factor (float, optional) – Factor to adjust brightness, default is 1.2.
- Returns:
List of lighter shades of the input color.
- Return type:
list
- class lib.plotting.style.ImageHandler(xpad=0.0, ypad=0.0, update_func=None)#
Bases:
matplotlib.legend_handler.HandlerBase
- create_artists(legend, orig_handle, xdescent, ydescent, width, height, fontsize, trans)#
Create artists for the legend.
- Parameters:
legend (matplotlib.legend.Legend) – The legend.
orig_handle – Original handle.
xdescent – X descent.
ydescent – Y descent.
width – Width.
height – Height.
fontsize – Font size.
trans – Transformation.
- Returns:
List of created artists.
- set_image(*array, image_path=None, image_stretch=(0, 0))#
Set the image data or path for the handler.
- Parameters:
array – Image data.
image_path – Path to the image file.
image_stretch – Stretch margins for the image, default is (0, 0).