clearplot.figure module

class Figure(size=None, dpmm=3.1496062992125986)

Bases: object

Figure class

__init__(size=None, dpmm=3.1496062992125986)

Instantiates a figure object

Parameters:
  • fig_size (list or tuple, optional) – Width and height of figure in mm

  • dpmm (float, optional) – Dots per mm

add_axes(**kwargs)

Adds a set of generic axes to the figure

Parameters:

axes.Axes() (Keyword arguments get passed to)

Returns:

ax

Return type:

axes object

add_color_bar(data_obj, **kwargs)

Places a color bar in the specified figure

Parameters:
  • data_obj (data object) – Object that the color bar pertains to.

  • Color_Bar() (See parameters in)

add_invisible_axes(**kwargs)

Adds a set of invisible axes to the figure.

Parameters:

axes.Invisible_Axes() (Keyword arguments get passed to)

Returns:

ax

Return type:

invisible axes object

add_line(x, **kwargs)

Adds a 2D line to the figure

Parameters:
  • x (2x2 numpy array) – Coordinates of the line in mm. First row contains the first point, and the second row contains the second point.

  • kwargs – Keyword arguments to matplotlib’s Line2D class

Returns:

line_obj

Return type:

matplotlib line object

See also

ax.add_line

adds line to axes

ax.annotate

adds an annotation to the axes

add_polygon(x, **kwargs)

Adds a polygon to the figure

Parameters:
  • x (Nx2 numpy array) – Coordinates of the polygon in mm. First row contains the first point, the second row contains the second point, etc.

  • kwargs – Keyword arguments to matplotlib’s Polygon class

Returns:

patch_obj

Return type:

matplotlib patch object

add_text(x, txt, **kwargs)

Adds text to the figure window

Parameters:
  • x (1x2 numpy array) – Coordinates of the text in mm

  • txt (string) – Text to add to the figure

  • kwargs – Keyword arguments to matplotlib’s text function

Returns:

txt_obj

Return type:

text object

See also

ax.add_text

adds text to axes

ax.annotate

adds an annotation to the axes

auto_adjust_layout(pad=2.0)

If the figure size and axes positions have not been explicitly specified, this method will resize the figure window and move the content to center all the content inside the window. If the content positions within the window have been explicitly specified, then the figure size will be adjusted, but the content positions relative to the lower left corner of the window will remain the same.

Parameters:

pad (float) – Padding on edges of figure, in mm.

close()

Closes the figure window

draw()

Convenience method that draws all the content in the figure window.

property fig_to_mm_trans

Gets a transformation object that converts normalized figure coordinates to mm, relative to the bottom left hand corner of the figure.

get_obj_bbox(obj)

Finds the coordinates of the bounding box surrounding an object, in mm, relative to the lower left corner of the figure window

Parameters:

obj (graphics primitive object) – object you wish to get the bounding box for

Returns:

bbox

Return type:

bounding box object

property mm_to_pix_trans

Gets a transformation object that converts mm to pixels, relative to the bottom left hand corner of the figure.

put_window_on_top()

Places the figure window on top of all other windows if interactive mode is on.

property renderer

Gets the current renderer

Returns:

renderer

Return type:

renderer object

save(file_name, dpmm=None, face_color=[0, 0, 0, 0], edge_color=[0, 0, 0, 0], transparent=True, bbox=None, pad=0)

Save the current figure.

Parameters:
  • file_name (string) – A string containing a path to a filename. If format is None and filename is a string, the output format is deduced from the extension of the filename. If the filename has no extension, the value of the rc parameter savefig.format is used.

  • dpmm ([ None | float > 0 ]) – The resolution in dots per mm.

  • face_color ([string | RGB color]) – The color of the figure background

  • edge_color ([string | RGB color]) – The color of the figure border

  • transparent (bool) – If True, the axes patches will all be transparent; the figure patch will also be transparent unless facecolor and/or edgecolor are specified via kwargs. This is useful, for example, for displaying a plot on top of a colored background on a web page. The transparency of these patches will be restored to their original values upon exit of this function.

  • bbox (bounding box object) – Bounding box of the region to be saved, in mm. If ‘tight’, then matplotlib will try to figure out the tightest bounding box that contains the figure content. If None, then the figure window will be saved as is.

  • pad (float) – Amount of padding in mm around the figure when bbox is ‘tight’.

property size

Get/set the figure size in mm. When changing the figure size, the figure content is left the same size.

property tight_bbox

Get/set the tight bounding box for the figure, in mm.

update()

Convenience method that draws any object that has been added to the the figure window.