bluemira.utilities.plot_tools

A collection of plotting tools.

Classes

Plot3D

Cheap and cheerful

BluemiraPathPatch3D

Class for a 3-D PathPatch which can actually be filled properly!

Functions

str_to_latex(→ str)

Create a new string which can be printed in LaTEX nicely.

make_gif(folder, figname[, file_format, clean])

Make a GIF image from a set of images with similar names in a folder.

save_figure(fig, name, *[, save, folder, dpi, file_format])

Saves a figure to the directory if save flag active

coordinates_to_path(→ matplotlib.path.Path)

Convert coordinates to path vertices.

smooth_contour_fill(ax, contour, cut_edge)

Smooths the edge of a filled contour with a set of coordinates

Module Contents

bluemira.utilities.plot_tools.str_to_latex(string: str) str

Create a new string which can be printed in LaTEX nicely.

Parameters:

string (str) – The string to be converted

Returns:

  • The mathified string

  • ’I_m_p’ ==> ‘$I_{m_{p}}$’

Return type:

str

bluemira.utilities.plot_tools.make_gif(folder: str, figname: str, file_format: str = 'png', *, clean: bool = True)

Make a GIF image from a set of images with similar names in a folder. Figures are sorted in increasing order based on a trailing number, e.g. ‘figure_A[1, 2, 3, ..].png’ Cleans up the temporary figure files (deletes!) Creates a GIF file in the folder directory

Parameters:
  • folder (str) – Full path folder name

  • figname (str) – Figure name prefix

  • file_format (str) – Figure filename extension

  • clean (bool) – Delete figures after completion?

bluemira.utilities.plot_tools.save_figure(fig, name, *, save=False, folder=None, dpi=600, file_format='svg', **kwargs)

Saves a figure to the directory if save flag active

bluemira.utilities.plot_tools.coordinates_to_path(x: numpy.ndarray, z: numpy.ndarray) matplotlib.path.Path

Convert coordinates to path vertices.

Returns:

The path vertices

Parameters:
  • x (numpy.ndarray)

  • z (numpy.ndarray)

Return type:

matplotlib.path.Path

bluemira.utilities.plot_tools.smooth_contour_fill(ax: matplotlib.axes.Axes, contour: matplotlib.contour.ContourSet, cut_edge: bluemira.geometry.coordinates.Coordinates)

Smooths the edge of a filled contour with a set of coordinates

Parameters:
class bluemira.utilities.plot_tools.Plot3D

Bases: mpl_toolkits.mplot3d.Axes3D

Inheritance diagram of bluemira.utilities.plot_tools.Plot3D

Cheap and cheerful

class bluemira.utilities.plot_tools.BluemiraPathPatch3D(path: matplotlib.path.Path, normal: numpy.ndarray, translation: numpy.ndarray | None = None, color: str = 'b', **kwargs)

Bases: mpl_toolkits.mplot3d.art3d.PathPatch3D

Inheritance diagram of bluemira.utilities.plot_tools.BluemiraPathPatch3D

Class for a 3-D PathPatch which can actually be filled properly!

Parameters:
  • path (matplotlib.path.Path) – The path object to plot in 3-D

  • normal (numpy.ndarray) – The 3-D normal vector of the face

  • translation (numpy.ndarray | None) – Translation vector to apply to the face

  • color (str) – The color to plot the fill

_patch2d
_path2d
_code3d
_facecolor3d
_segment3d
__getattr__(key: str)

Transfer the key getattr to underlying PathPatch object.

Returns:

The key’s value

Parameters:

key (str)