pylbo.visualisation.utils
Module Contents
Functions
|
Simple decorator, when a routine is wrapped with this the plot will be |
|
Ensures that a given attribute is set. |
|
Converts an eigenfunction name to latex formatting. Numbers are replaced with a |
|
Maps the background name to latex formatting. |
|
Returns the validated eigenfunction name. |
|
Validates the location of the textbox. |
|
Returns the coordinates of the textbox. |
|
Convenience method to add a textbox to the given axes. |
|
Creates a textbox in one of the corners of the specified axis. This method is meant |
Attributes
- pylbo.visualisation.utils.refresh_plot(f: callable) callable [source]
Simple decorator, when a routine is wrapped with this the plot will be cleared and redrawn on calling it. Useful for when the scaling is changed or artists are added/removed.
- pylbo.visualisation.utils.ensure_attr_set(obj: Any, attr: str) None [source]
Ensures that a given attribute is set.
- Parameters:
obj (Any) – The object to check.
attr (str) – The attribute to check.
- Raises:
ValueError – If the attribute is not set.
- pylbo.visualisation.utils.ef_name_to_latex(ef_name: str, geometry: str = 'Cartesian', real_part: bool = None) str [source]
Converts an eigenfunction name to latex formatting. Numbers are replaced with a suffix corresponding to the geometry: \((1, 2, 3)\) becomes \((x, y, z)\) for Cartesian and \((r, \theta, z)\) for cylindrical geometries. Symbols and letters are also converted to LaTeX.
- pylbo.visualisation.utils.background_name_to_latex(bg_name: str) str [source]
Maps the background name to latex formatting.
- pylbo.visualisation.utils.validate_ef_name(ds, ef_name: str) str [source]
Returns the validated eigenfunction name.
- Parameters:
ds (LegolasDataSet) – The dataset containing the eigenfunctions.
ef_name (str) – The name of the eigenfunction.
- Raises:
ValueError – If the eigenfunction name is not valid.
- Returns:
The validated eigenfunction name.
- Return type:
- pylbo.visualisation.utils._validate_textbox_location(loc: str) str [source]
Validates the location of the textbox.
- Parameters:
loc (str) – The location of the textbox.
- Raises:
ValueError – If the location is not one of “top left”, “top right”, “bottom left” or “bottom right”.
- Returns:
The validated location.
- Return type:
- pylbo.visualisation.utils._get_textbox_axes_coords(loc: str, outside: bool, width: float, height: float)[source]
Returns the coordinates of the textbox.
- pylbo.visualisation.utils.add_textbox_to_axes(ax: matplotlib.axes.Axes, text: str, x: float, y: float, coords: str = 'axes', fs: int = 15, alpha: float = 0.2, halign: str = 'center', color: str = 'grey', textcolor: str = 'black', boxstyle: str = 'round') matplotlib.axes.Axes.text [source]
Convenience method to add a textbox to the given axes.
- Parameters:
ax (Axes) – The axes to add the textbox to.
text (str) – The text to add to the textbox.
x (float) – The x-coordinate of the textbox.
y (float) – The y-coordinate of the textbox.
coords (str, optional) – The coordinate system of the textbox. The default is “axes”, options are “axes”, “figure”, and “data”.
fs (int, optional) – The fontsize of the textbox. The default is 15.
alpha (float, optional) – The alpha value of the textbox. The default is 0.2.
halign (str, optional) – The horizontal alignment of the textbox. The default is “center”.
color (str, optional) – The color of the textbox. The default is “grey”.
textcolor (str, optional) – The color of the text. The default is “black”.
boxstyle (str, optional) – The style of the textbox. The default is “round”.
- Returns:
The textbox.
- Return type:
text
- pylbo.visualisation.utils.add_axis_label(ax: matplotlib.axes.Axes, text: str, loc: str = 'top left', fs: int = 15, alpha: float = 0.2, color: str = 'grey', textcolor: str = 'black', boxstyle: str = 'round', bold: bool = False, outside: bool = False) matplotlib.axes.Axes.text [source]
Creates a textbox in one of the corners of the specified axis. This method is meant to create panel labels without having to manually specify the coordinates of the textbox.
- Parameters:
ax (Axes) – The axes to add the textbox to.
text (str) – The text to add to the textbox.
loc (str, optional) – The location of the textbox. The default is “top left”, options are “top right”, “bottom left” and “bottom right”.
fs (int, optional) – The fontsize of the textbox. The default is 15.
alpha (float, optional) – The alpha value of the textbox. The default is 0.2.
color (str, optional) – The color of the textbox. The default is “grey”.
textcolor (str, optional) – The color of the text. The default is “black”.
boxstyle (str, optional) – The style of the textbox. The default is “round”. If None is passed no box will be drawn.
bold (bool, optional) – Whether to bold the text. The default is False.
outside (bool, optional) – Whether to place the textbox outside of the axis. The default is False.
- Raises:
ValueError – If the location is not one of “top left”, “top right”, “bottom left” or “bottom right”.
- Returns:
The textbox.
- Return type:
text