qom.ui.plotters.matplotlib module¶
Module to handle matplotlib plots.
- class qom.ui.plotters.matplotlib.MPLPlotter(axes: dict, params: dict, cb_update=None)¶
Bases:
BasePlotter
Class to handle matplotlib plots.
Initializes
axes
,params
andplots
.- Parameters:
axes (dict) – Axes for the plot containing one or more keys for the axes (
'X'
, ‘Y’ or ‘Z’), each either a list of values, or a dictionary. Refer toqom.ui.plotters.base.BasePlotter
for currently supported keys.params (dict) – Parameters of the plot. Refer to
qom.ui.plotters.base.BasePlotter
for all available options.
- _get_colors_sizes_styles(dim)¶
Method to obtain the colors, sizes and styles for 1D plots.
- Parameters:
dim (int) – Dimension of the Y-axis.
- Returns:
colors (list) – Colors for each plot.
sizes (list) – Sizes for each plot.
styles (list) – Styles for each plot.
- _get_font_props(font_dict: dict)¶
Method to convert font dictionary to
FontProperties
object.- Parameters:
font_dict (dict) – Dictionary of font properties.
- Returns:
font_props – Font properties.
- Return type:
matplotlib.font_manager.FontProperties
- _init_1D(dim=0, ax_twin=None)¶
Method to initialize 1D plots.
- Parameters:
dim (int) – Dimension of the Y-axis.
- _init_2D()¶
Method to initialize 2D plots.
- _init_3D()¶
Method to initialize 3D plots.
- _resize_plot(width: float = 4.8, height: float = 4.8)¶
Method to resize the plot.
- Parameters:
width (float) – Width of the figure.
height (float) – Height of the figure.
- _update_1D(vs, xs, ax_twin=None)¶
Method to udpate 1D plots.
- Parameters:
vs (list or numpy.ndarray) – V-axis values.
xs (list or numpy.ndarray) – X-axis values.
ax_twin (
matplotlib.axes.Axes
) – Twin axis of the figure.
- _update_2D(vs)¶
Method to udpate 2D plots.
- Parameters:
vs (list or numpy.ndarray) – V-axis values.
- _update_3D(vs, xs, ys, zs)¶
Method to udpate 3D plots.
- Parameters:
vs (list or numpy.ndarray) – V-axis values.
xs (list or numpy.ndarray) – X-axis data.
ys (list or numpy.ndarray) – Y-axis data.
zs (list or numpy.ndarray) – Z-axis data.
- _update_axis(ax, ax_name: str, ax_data: dict)¶
Method to update an axis.
- Parameters:
ax (
matplotlib.axes.Axes
) – Axis of the plot.ax_name (str) – Name of the axis.
ax_data (dict) – Data for the axis.
- add_scatter(vs, xs, color: str = 'k', size: float = 1.0, style: str = '.', zorder=1)¶
Method to add a scatter plot.
- Parameters:
vs (list or numpy.ndarray) – V-axis values.
xs (list or numpy.ndarray) – X-axis data.
color (str or int) – Color of the plot.
size (int) – Size of the plot.
style (str) – Marker style of the plot.
zorder (int, default=1) – Position of the scatter plot in the Z-axis.
- cbar_positions = {'bottom': <function MPLPlotter.<lambda>>, 'left': <function MPLPlotter.<lambda>>, 'right': <function MPLPlotter.<lambda>>, 'top': <function MPLPlotter.<lambda>>}¶
Positions ofthe color bar.
- Type:
dict
- cbar_positions_toggled = {'bottom': <function MPLPlotter.<lambda>>, 'left': <function MPLPlotter.<lambda>>, 'right': <function MPLPlotter.<lambda>>, 'top': <function MPLPlotter.<lambda>>}¶
Toggled positions ofthe color bar.
- Type:
dict
- close()¶
Method to close the plotter.
- desc = 'MatPlotLib Plotter'¶
Description of the plotter.
- Type:
str
- get_current_axis()¶
Method to obtain the axes of the figure.
- Returns:
axes – Axes of the figure.
- Return type:
matplotlib.axes.Axes
- get_current_figure()¶
Method to obtain the current figure.
- Returns:
fig – Current figure.
- Return type:
matplotlib.pyplot.figure
- name = 'MPLPlotter'¶
Name of the plotter.
- Type:
str
- save(filename: str, dpi: int = 300)¶
Method to save the figure.
- Parameters:
filename (str) – Name of the saved file.
dpi (int) – DPI of the saved file.
- set_cbar(mini: float = 0, maxi: float = 0, prec: int = 2)¶
Method to set the colorbar for the figure.
- Parameters:
mini (float) – Minimum value displayed. Default is 0.
maxi (float) – Maximum value displayed. Default is 0.
prec (int) – Precision upto which the values are displayed. Default is 2.
- show(hold: bool = True)¶
Method to display the figure.
- Parameters:
hold (bool, default=True) – Option to hold the plot.
- update(vs, xs=None, ys=None, zs=None)¶
Method to update the figure.
- Parameters:
vs (list or numpy.ndarray) – V-axis data.
xs (list or numpy.ndarray, optional) – X-axis data.
ys (list or numpy.ndarray, optional) – Y-axis data.
zs (list or numpy.ndarray, optional) – Z-axis data.
- update_twin_axis(vs, xs)¶
Method to create and update a twin axis of a 1D plot.
- Parameters:
vs (list or numpy.ndarray) – V-axis data.
xs (list or numpy.ndarray) – X-axis data.
- Returns:
ax_twin – The twin axis.
- Return type:
matplotlib.axes.Axes