Plots#

The plots module contains classes for generating plots. The base class for plotting is Plot.

class Plot(canvas)[source]

General plot.

Parameters:
canvascanvas

Canvas for embedding in GUI.

Attributes:
canvascanvas

Qt canvas.

figfigure

Canvas figure.

axaxis

Figure axis.

Methods

get_aspect()

Apect ratio of figure.

set_aspect()

Update apect ratio of figure.

set_labels()

Update axis titles and labels.

clear_canvas()

Clear canvas and remove axis.

draw_canvas()

Draw canvas.

tight_layout()

Use a tight layout for figure.

save_figure()

Save figure to file.

clear_canvas()[source]

Clear canvas and remove axis.

draw_canvas()[source]

Draw canvas.

get_aspect()[source]

Apect ratio of figure.

Returns:
valuefloat

Ratio of height to width.

save_figure(filename)[source]

Save figure to file.

Parameters:
filenamestr

Name of file. Allowed extensions are *.pdf and *.png.

set_aspect(value)[source]

Update apect ratio of figure.

Parameters:
valuefloat

Ratio of height to width.

set_axis_scales(xscale='linear', yscale='linear')[source]

Update axis scales.

Parameters:
xscalestr

Axis scale type. Allowed values are 'linear', 'log', 'symlog', or 'logit'. Default is 'linear'.

yscalestr

Axis scale type. Allowed values are 'linear', 'log', 'symlog', or 'logit'. Default is 'linear'.

set_labels(title='', xlabel='', ylabel='')[source]

Update axis titles and labels.

Parameters:
titlestr

Title of the figure. Default is ''.

xlabelstr

Label for x-axis. Default is ''.

ylabelstr

Label for y-axis. Default is ''.

show()[source]

Show figure.

tight_layout(pad=3.24)[source]

Use a tight layout for figure.

Parameters:
padfloat, optional

Pad size. Default is 3.24.

There are classes for generating typical xy-plots, intensity maps, and scatter plots.

class HeatMap(canvas)[source]

Intensity heat map plot.

Parameters:
canvascanvas

Canvas for embedding in GUI.

Attributes:
imimage

Image plot.

normnormalization

Color normalization.

cmapcolormap

Colormap.

Methods

set_normalization()

Update data normalization.

update_normalization()

Replace normalization.

update_colormap()

Replace colormap.

create_colorbar()

Create colorbar.

remove_colorbar()

Remove colorbar.

set_colorbar_label()

Update colorbar label.

reset_color_limits()

Autoscale color limits.

update_data()

Replace data.

get_data()

Data.

plot_data()

Plot data.

transform_axes()

Skew axes according to a transformation matrix.

draw_line()

Draw line with specified extents.

add_text()

Add text at specified location.

add_text(x, y, s, color='w')[source]

Add text at specified location.

Parameters:
x, yfloat

Text location.

sstr

Text string.

colorstr, optional

Text color. The default is 'w'`.

create_colorbar(orientation='vertical', norm='linear')[source]

Create colorbar.

Parameters:
orientationTYPE, optional

Orientation of colorbar. Either 'vertical' or 'horizontal'. The default is 'vertical'.

normstr, optional

Data normalization. Options are 'linear', 'logarithmic', or 'symlog'. The default is 'linear'.

draw_line(xlim=None, ylim=None)[source]

Draw line with specified extents. If not specified, extents are over the entire axis limits.

Parameters:
xlimlist, optional

Extents along x-axis. The default is None.

ylimlist, optional

Extents along y-axis. The default is None.

Returns:
None.
get_data()[source]

Data.

Returns:
data2d array

Image values.

plot_data(data, min_x, min_y, max_x, max_y, matrix=array([[1., 0.], [0., 1.]]))[source]

Plot data.

Parameters:
data2d array

Image values.

min_x, min_yfloat

Minimumx extents.

max_x, max_yfloat

Maxium extents.

matrix2d array, 2x2, optional

Transformation matrix. The default is the identity matrix.

remove_colorbar()[source]

Remove colorbar.

reset_color_limits()[source]

Autoscale color limits.

set_colorbar_label(label)[source]

Update colorbar label.

Parameters:
labelstr

Colorbar label.

set_normalization(vmin, vmax, norm='linear')[source]

Update data normalization.

Parameters:
vminfloat

Minimum data value.

vmaxfloat

Maximum data value.

normstr, optional

Data normalization. Options are 'linear', 'logarithmic', or 'symlog'. The default is 'linear'.

transform_axes(matrix)[source]

Skew axes according to a transformation matrix.

Parameters:
matrix2d array, 2x2

Transformation matrix.

update_colormap(category='sequential')[source]

Replace colormap.

Parameters:
categorystr, optional

Update colormap. Options are 'sequential', 'diverging', or 'binary'. The default is 'sequential'.

update_data(data, vmin, vmax)[source]

Replace data.

Parameters:
data2d array

Image values.

vminfloat, optional

Minimum data value.

vmaxfloat, optional

Maximum data value.

update_normalization(norm='linear')[source]

Replace normalization.

Parameters:
normstr, optional

Data normalization. Options are 'linear', 'logarithmic', or 'symlog'. The default is 'linear'.

class Line(canvas)[source]

Line plot.

Parameters:
canvascanvas

Canvas for embedding in GUI.

Attributes:
pllist

Line plots.

colorscolor cycler

Cycle of colors for plotting.

Methods

set_labels()

Update axis titles and labels.

clear_canvas()

Clear canvas and remove axis.

clear_lines()

Clear line plots.

set_normalization()

Update data normalization.

set_limits()

Update data limits.

reset_view()

Autoscale data.

update_data()

Replace indexed data.

get_data()

Indexed data.

plot_data()

Plot data sequentially.

show_legend()

Display legend.

draw_horizontal()

Draw horizontal line.

use_scientific()

Use scientific notation.

clear_canvas()[source]

Clear canvas and remove axis.

clear_lines()[source]

Clear line plots.

draw_horizontal()[source]

Draw horizontal line at zero ordinate.

get_data(i=0)[source]

Indexed data.

Parameters:
iint, optional

Index of dataset. The default is 0.

Returns:
x1d array

Data correpsonding to abscissa.

y1d array

Data correpsonding to ordinate.

plot_data(x, y, yerr=None, marker='o', label='', twin=False)[source]

Plot data sequentially.

Parameters:
x1d array or list

Data correpsonding to abscissa.

y1d array or list

Data correpsonding to ordinate.

yerr1d array or list, optional

Error correpsonding to ordinate. The default is None.

markerstr, optional

Marker symbol. The default is 'o'.

labelstr, optional

Label for legend. The default is ''.

twinbool, optional

Plot on twin axis. The default is False.

reset_view(twin=False)[source]

Autoscale data. Limits and scale are reset.

Parameters:
twinbool, optional

Apply to twin axis. The default is False.

set_labels(title='', xlabel='', ylabel='', twin_ylabel='')[source]

Update axis titles and labels.

Parameters:
titlestr

Title of the figure. Default is ''.

xlabelstr

Label for x-axis. Default is ''.

ylabelstr

Label for y-axis. Default is ''.

twin_ylabelstr

Label for twin y-axis. Default is ''.

set_limits(vmin=None, vmax=None, twin=False)[source]

Update data limits.

Parameters:
vminfloat, optional

Minimum ordinate value. The default is None.

vmaxfloat, optional

Maximum ordinate value. The default is None.

twinbool, optional

Apply to twin axis. The default is False.

set_normalization(norm='linear', twin=False)[source]

Update data normalization.

Parameters:
normstr, optional

Data normalization. Options are 'linear', 'logarithmic', or 'symlog'. The default is 'linear'.

twinbool, optional

Apply to twin axis. The default is False.

show_legend()[source]

Display legend.

update_data(x, y, i=0)[source]

Replace indexed data on existing plot.

Parameters:
x1d array or list

Data correpsonding to abscissa.

y1d array or list

Data correpsonding to ordinate.

iint, optional

Index of dataset. The default is 0.

use_scientific(twin=False)[source]

Use scientific notation.

Parameters:
twinbool, optional

Apply to twin axis. The default is False.

class Scatter(canvas)[source]

Scatter plot.

Parameters:
canvascanvas

Canvas for embedding in GUI.

Attributes:
scscatter

Scatter plot.

normnormalization

Color normalization.

cmapcolormap

Colormap.

Methods

set_normalization()

Update data normalization.

update_normalization()

Replace normalization.

update_colormap()

Replace colormap.

create_colorbar()

Create colorbar.

remove_colorbar()

Remove colorbar.

set_colorbar_label()

Update colorbar label.

reset_color_limits()

Autoscale color limits.

update_data()

Replace data.

get_data()

Data.

plot_data()

Plot data.

create_colorbar(orientation='vertical', norm='linear')[source]

Create colorbar.

Parameters:
orientationTYPE, optional

Orientation of colorbar. Either 'vertical' or 'horizontal'. The default is 'vertical'.

normstr, optional

Data normalization. Options are 'linear', 'logarithmic', or 'symlog'. The default is 'linear'.

get_data()[source]

Data.

Returns:
c1d array

Scatter point values.

plot_data(x, y, c)[source]

Plot data.

Parameters:
x, y1d array

Scatter point coordinates.

c1d array

Scatter point values.

remove_colorbar()[source]

Remove colorbar.

reset_colorbar_limits()[source]

Autoscale color limits.

set_colorbar_label(label)[source]

Update colorbar label.

Parameters:
labelstr

Colorbar label.

set_normalization(vmin, vmax, norm='linear')[source]

Update data normalization.

Parameters:
vminfloat

Minimum data value.

vmaxfloat

Maximum data value.

normstr, optional

Data normalization. Options are 'linear', 'logarithmic', or 'symlog'. The default is 'linear'.

update_colormap(category='sequential')[source]

Replace colormap.

Parameters:
categorystr, optional

Update colormap. Options are 'sequential', 'diverging', or 'binary'. The default is 'sequential'.

update_data(c, vmin, vmax)[source]

Replace data.

Parameters:
c1d array

Scatter point values.

vminfloat, optional

Minimum data value.

vmaxfloat, optional

Maximum data value.

update_normalization(norm='linear')[source]

Replace normalization.

Parameters:
normstr, optional

Data normalization. Options are 'linear', 'logarithmic', or 'symlog'. The default is 'linear'.