sarcasm.plot_utils
Classes
Helper function and parameters for plotting |
Module Contents
- class sarcasm.plot_utils.PlotUtils[source]
Helper function and parameters for plotting
- fontsize = 8
- markersize = 3
- labelpad = 1
- dpi = 600
- save_format = 'png'
- width_1cols = 3.5
- width_1p5cols = 5
- width_2cols = 7.1
- static label_all_panels(axs: dict, offset=(-0.1, 1.1), color='k')[source]
Labels all panels in a given dictionary of Axes objects.
- Parameters:
axs (dict) – A dictionary of Axes objects.
offset (tuple, optional) – The x and y offset for the labels. Defaults to (-0.1, 1.1).
color (str, optional) – The color of the labels. Defaults to ‘k’ (black).
- static label_panel(ax: matplotlib.axes.Axes, label: str, offset=(-0.1, 1.1), color='k')[source]
Labels a single panel with the specified label.
- Parameters:
ax (matplotlib.axes.Axes) – The Axes object representing the panel to be labeled.
label (str) – The label to be displayed.
offset (tuple, optional) – The x and y offset for the label. Defaults to (-0.1, 1.1).
color (str, optional) – The color of the label. Defaults to ‘k’ (black).
- static remove_all_spines(axs: dict)[source]
Removes the spines from all panels in a given dictionary of Axes objects.
- Parameters:
axs (dict) – A dictionary of Axes objects.
- static remove_spines(ax)[source]
Removes the spines from a single panel.
- Parameters:
ax (matplotlib.axes.Axes) – The Axes object representing the panel.
- static change_color_spines(ax, c='w', linewidth=1)[source]
Changes the color of the spines (borders) of a single panel.
- Parameters:
ax (matplotlib.axes.Axes) – The Axes object representing the panel.
c (str, optional) – The color of the spines. Defaults to ‘w’ (white).
- static remove_ticks(ax)[source]
Removes the ticks (markings) from both x-axis and y-axis of a single panel.
- Parameters:
ax (matplotlib.axes.Axes) – The Axes object representing the panel.
- static polish_xticks(ax, major, minor, pad=3, radian=False)[source]
Formats and polishes the x-ticks (markings) of a single panel.
- Parameters:
ax (matplotlib.axes.Axes) – The Axes object representing the panel.
major (float) – The major tick spacing.
minor (float) – The minor tick spacing.
pad (float, optional) – The padding between the x-axis and the tick labels. Defaults to 3.
radian (bool, optional) – Flag to format ticks in radians. Defaults to False.
- static polish_yticks(ax, major, minor, pad=3)[source]
Formats and polishes the y-ticks (markings) of a single panel.
- Parameters:
ax (matplotlib.axes.Axes) – The Axes object representing the panel.
major (float) – The major tick spacing.
minor (float) – The minor tick spacing.
pad (float, optional) – The padding between the y-axis and the tick labels. Defaults to 3.
- static plot_box(ax, xlim, ylim, c='w', lw=1, linestyle='-')[source]
Plots a box around a given area defined by the x-axis and y-axis limits.
- Parameters:
ax (matplotlib.axes.Axes) – The Axes object representing the panel.
xlim (tuple) – The x-axis limits of the box.
ylim (tuple) – The y-axis limits of the box.
c (str, optional) – The color of the box. Defaults to ‘w’ (white).
lw (float, optional) – The linewidth of the box. Defaults to 1.
linestyle (str, optional) – The linestyle of the box. Defaults to ‘-’ (solid line).
- static jitter(x, y, width=0.02)[source]
Adds a small amount of random noise to the x-coordinates of the points to prevent overlap.
- Parameters:
x (array-like) – The x-coordinates of the points.
y (array-like) – The y-coordinates of the points.
width (float, optional) – The maximum width of the random noise. Defaults to 0.02.
- Returns:
The jittered x-coordinates of the points.
- Return type:
array-like
- boxplot_with_points(data, labels, width=0.1, alpha=0.5, s=10, whis=(5, 95), rotation=90)[source]
Creates a boxplot with scattered points.
- Parameters:
ax (matplotlib.axes.Axes) – The axes to draw the plot on.
data (array-like) – The data to plot.
labels (list of str) – The labels for the boxplots.
width (float, optional) – The width of the boxplots. Defaults to 1.25.
alpha (float, optional) – The alpha value for the points. Defaults to 0.005.
s (int, optional) – The size of the points. Defaults to 10.
whis (tuple of float, optional) – The whisker range for the boxplots. Defaults to (5, 95).
rotation (int, optional) – The rotation angle for the x-axis labels. Defaults to 90.
- Return type:
None
- static plot_func_to_img(sarc_obj: sarcasm.SarcAsM | sarcasm.Motion, plot_func, img_filename, figsize=(6, 6), scalebar=False, dpi=300)[source]
Generates a plot using a specified plotting function and saves it as an image file.
- Parameters:
sarc_obj (object) – The object containing data to be plotted, which can be an instance of SarcAsM or Motion
plot_func (function) – The plotting function that takes an Axes object, a sarcomere object, and a boolean indicating whether to include a scalebar. It should plot the data onto the provided Axes object.
img_filename (str) – The filename (including path) where the image will be saved.
figsize (tuple of int or float, optional) – The size of the figure (width, height) in inches. Default is (6, 6).
scalebar (bool, optional) – Indicates whether a scalebar should be included in the plot. Default is False.
dpi (int, optional) – Quality of the plot. Default is 300.