clearplot documentation - read the docs...clearplot documentation, release 1.2.0 clearplot creates...

83
Clearplot Documentation Release 1.2.0 Benjamin Reedlunn May 24, 2017

Upload: others

Post on 22-Jan-2021

26 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot DocumentationRelease 1.2.0

Benjamin Reedlunn

May 24, 2017

Page 2: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create
Page 3: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Contents

1 Contents 31.1 Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.2 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41.3 clearplot package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241.4 Version History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63

2 Primary Features 67

3 Bug Fixes 69

4 Feature Requests and Enhancements 71

5 Potential Improvements 73

Python Module Index 75

i

Page 4: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

ii

Page 5: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

Clearplot creates publication quality plots using matplotlib. The project began as an effort to create lucid plots with acertain style, like the example below.

Over time, we have also revamped matplotlib’s user interface, and added a few new features. Although the documen-tation has detailed descriptions of the clearplot syntax, probably the best way to get started is to look at the examples.

Contents 1

Page 6: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

2 Contents

Page 7: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

CHAPTER 1

Contents

Installation

Easy Way

1. Install clearplot using pip install -v clearplot from the command line.

(a) This will download clearplot from PyPI, install it on your PYTHONPATH, and install the custom fonts inthe proper directory. The -v tells pip to be verbose, so you can see what pip is doing.

(b) If pip has trouble connecting to the PyPI server, you can download clearplot from PyPI’s website and runpip install -v [path], where [path] is the path to the downloaded tarball.

Hard (Manual) Way

1. Get a recent copy of clearplot using git clone https://github.com/breedlun/clearplot.

2. Append the clearplot directory to your PYTHONPATH.

3. Load a python interpreter. Verify that you can run import clearplot without any errors.

4. Place the custom fonts where matplotlib can find them.

(a) Find where Matplotlib stores its True Type fonts. In a python interpreter, type the following two com-mands: import matplotlib, matplotlib.matplotlib_fname(). On a mac, you shouldget something like .../site-packages/matplotlib/mpl-data/matplotlibrc. The TrueType fonts are stored in .../site-packages/matplotlib/mpl-data/fonts/ttf/.

(b) Grab the fonts in the directories inside clearplot/Font_Files/ and place them in: .../python2.7/site-packages/matplotlib/mpl-data/fonts/ttf/.

(c) Find where Matplotlib stores its cache files. In a python interpreter, enter matplotlib.get_cachedir(). On a mac, you should get something like /Users/[username]/.matplotlib.

3

Page 8: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

(d) Go to /Users/[username]/.matplotlib and delete fontList.cache. Next time matplotlibis imported the cache file will be rebuilt.

(e) If you run into trouble, or want more information, see this post.

Optional Additional Steps

1. If you are using the Spyder IDE on a Mac, you may need to change the matplotlib backend loaded by Spyder’sscientific startup script. The MacOSX backend and the TkAgg backend both have issues (see this post and thispost for more information). If you are running into these problems, you must:

1. Go to Spyder Preferences->Console->External Modules and set the GUI Backend to Qt4Agg.

2. Go to Spyder Preferences->Console->Advanced Settings and select “Use the following startup script” to selectthe scientific_startup.py script.

3. Restart Spyder.

2. Install the custom fonts on your system so they can be accessed by other applications like Adobe Illustrator andInkscape.

(a) Find where Matplotlib stores its True Type fonts. In a python interpreter, type the following two com-mands: import matplotlib, matplotlib.matplotlib_fname(). On a mac you shouldget something like: .../site-packages/matplotlib/mpl-data/matplotlibrc. The cus-tom fonts, such as TeXGyreHeros-txfonts, should have been installed in .../site-packages/matplotlib/mpl-data/fonts/ttf/.

2. For Adobe Illustrator on a Mac, you can simply open the Font Book application (/Applications/Utilities/Font Book) and “drag and drop” the font files into the Font Book window.

3. For Inkscape on a Mac, you must copy the font files into the main font folder, not the user font folder. The mainfont folder is located at /Library/Fonts.

4. I do not know how to install fonts on Windows or Linux, but I am sure there are instructions online.

Examples

These examples serve to showcase clearplot’s capabilities, help new users get clearplot’s syntax right, and verify thatclearplot is working correctly. Click on any image to see full size image and source code.

Barebones

Default everything.

import clearplot.plot_functions as pfimport numpy as np

x = np.arange(0,10,0.01)y = np.sqrt(x)pf.plot('bare_bones.png', x, y);

4 Chapter 1. Contents

Page 9: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

Basic

Axis labels are in LaTeX syntax. Axis units are automatically wrapped with parentheses. Upper x-limit and tick markspacing for the x-axis are user specified.

import clearplot.plot_functions as pfimport numpy as np

x = np.arange(0,10,0.01)y = np.sqrt(x)

pf.plot('basic.png', x, y, \x_label = ['\phi', '\%'], y_label = ['\psi', 'GPa'], \

x_lim = ['auto', 16], x_tick = 4);

1.2. Examples 5

Page 10: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

No Axis Arrows

If you do not like the axis arrows, it is easy to turn them off. Axis labels default to math mode, so you must usecommands like \sf{} to obtain non-italic text.

import clearplot.paramsimport clearplot.plot_functions as pfimport numpy as np

clearplot.params.axis_arrow_bool = False

x = np.arange(0,10,0.01)y = np.sqrt(x)

pf.plot('no_axis_arrows.png', x, y, \x_label = ['\sf{Volume\;Change}', '\%'], \y_label = ['\psi', 'GPa']);

6 Chapter 1. Contents

Page 11: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

Two Curves - Legend

Multiple curves on the same set of axes. Legend displayed. Dashed black line cleary locates zero.

import clearplot.plot_functions as pfimport numpy as np

xa = np.arange(0,10,0.01)ya = np.sqrt(xa)xb = xayb = 3.0 * (xb/10)**3 - 2.0 * (xb/10)**2

[fig, ax, curves] = pf.plot('two_curves-legend.png', [xa, xb], [ya, yb], \labels = ['\kappa_y', '\kappa_z'], \x_label = ['\zeta_{yz}', 'in'], y_label = ['\kappa_j', 'lbf'])

1.2. Examples 7

Page 12: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

Two Curves - Labels - No Units

Multiple curves on the same set of axes. Axes do not have units. Curves labeled. (Label positions can be pickedinteractively if ax.label_curves() has the keyword argument pick = True.)

import clearplot.plot_functions as pfimport numpy as np

xa = np.arange(0,10,0.01)ya = np.sqrt(xa)xb = xayb = np.log(xb + 1.0)

[fig, ax, curves] = pf.plot('', [xa, xb], [ya, yb], \labels = ['\Omega_1', '\Omega_2'], legend = False, \x_label = ['\omega_{x}'], y_label = ['\Omega'])

ax.label_curves(ndx = [500, 530], angles = [120, -60])fig.save('two_curves-labels-no_units.png')

8 Chapter 1. Contents

Page 13: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

Two Y Axes

Object oriented interface. Two y-axes. Two curves on the first y-axis. One curve on the second y-axis. User specifiedlimits for y-axes. Legends displayed.

import clearplot.figure as figureimport numpy as np

xa = np.arange(0,10,0.01)ya = np.sqrt(xa)xb = xayb = 3.0 * (xb/10)**3 - 2.0 * (xb/10)**2xc = xayc = 1.0/2.0 * xc**2.0

fig = figure.Figure()ax1 = fig.add_axes()ax1.plot([xa, xb], [ya, yb], labels = ['\alpha', '\beta'])ax1.x_label = ['A', 'mm^2']ax1.y_label = ['\alpha,\,\beta', 'kJ']ax1.y_lim = [-1,'auto']ax1.add_legend(loc = 'upper left')

ax2 = fig.add_axes(share_x_ax = ax1)ax2.plot([xc], [yc], labels = ['\gamma'], line_colors = [0,0,1])ax2.add_legend(loc = 'upper right')ax2.y_lim = [-20, 80]ax2.y_label = ['\gamma','\mu m']

fig.auto_adjust_layout()

1.2. Examples 9

Page 14: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

fig.save('two_y_axes.png')

Log - Log Plot

Log - Log Plot. Data points denoted by circular markers. User specified limits for x-axis.

import clearplot.plot_functions as pfimport numpy as np

x = np.array([33.0, 4.0, 1.0, 1.0/7.0, 1.0/10.0, 1.0/25.0, 1.0/60.0, \1.0/120.0, 1.0/439.0, 1.0/645.0])

y = 4.0 * x**0.5

pf.plot('log_log_plot.png', x, y, \x_label = ['h\,/\,h_o'], y_label = ['e'], \x_scale = 'log', y_scale = 'log', x_lim = ['auto', 1000], \marker_shapes = 'o', marker_edge_widths = 0)

10 Chapter 1. Contents

Page 15: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

Arrows - Custom Tick Labels

Arrows labeling the curve direction (Arrows positions can be picked interactively when ax.add_arrowheads_to_curves() is given the pick = True keyword argument.) User specified list ofstrings for x-axis and y-axis tick labels.

import clearplot.plot_functions as pfimport numpy as np

xa = np.arange(0, 1.001, 0.001)ya = np.sqrt(0.0625 - ((xa-0.5)/2.0)**2.0) * 8.0xa = np.append(xa, np.flipud(xa))ya = np.append(ya, -np.flipud(ya))xb = xa * 2.35yb = ya * 1.5

[fig, ax, curves] = pf.plot('', [xa, xb], [ya, yb], \x_label = ['\lambda_{zz}'], y_label = ['\rho_{r\theta}', 'Btu']);

ax.x_tick_labels = ['0', '\pi/2', '\pi', '3\pi/2', '2\pi', '5\pi/4']ax.y_tick_labels = ['\alpha', '', '0', '', '\beta']ax.add_arrowheads_to_curves(ndx = [[800, 1300], [800, 1300]])fig.save('arrows-custom_tick_labels.png')

1.2. Examples 11

Page 16: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

Vertically Stacked Plots

Object oriented interface. Two vertically stacked plots, with the same x-axes. User specified limits and tick spacingsfor y-axes. User specified line colors.

import clearplot.figure as figureimport numpy as np

xa = np.arange(0,10,0.01)ya = np.sqrt(xa)xb = xayb = 1.0/2.0 * xb**2.0

fig = figure.Figure()ax1 = fig.add_axes()ax1.plot([xa], [ya], curve_colors = [0, 0.5, 0.5])ax1.x_label = ['t', '10^3\,s']ax1.y_label = ['\delta', 'mm']ax1.y_lim = [0,4]ax1.y_tick = 1;

ax2 = fig.add_axes(link_x_ax = ax1)ax2.plot([xb], [yb*1.5], curve_colors = [1, 0.5, 0])ax2.y_tick = 50.0ax2.y_label = ['P', 'N']

fig.auto_adjust_layout()fig.save('vertically_stacked.png')

12 Chapter 1. Contents

Page 17: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

LaTeX Typesetting

By default, matplotlib uses mathtext to interpret LaTeX strings. It usually works quite well, but it is not perfect. Forexample, mathtext does not distinguish between textstyle and displaystyle, so fractions look too small and it is notpossible to make integral signs smaller. Fortunately, figure text can be typeset using true LaTeX. Typesetting withLaTeX is significantly slower when saving as a pdf, but sometimes it is needed to get things right.

import clearplotimport clearplot.plot_functions as pfimport numpy as np

x = np.arange(0,10,0.01)y = np.sqrt(x)

1.2. Examples 13

Page 18: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

pf.plot('math_text_typesetting.png', x, y, \x_label = ['\int_0^x \exp\left[\hat{x}\right]\,\mathrm{d}\hat{x}'], \y_label = ['\frac{P}{A}', 'GPa'])

clearplot.params.use_latex(True)[fig, ax, curves] = pf.plot('LaTeX_typesetting.png', x, y, \

x_label = ['\int_0^x \exp\left[\hat{x}\right]\,\mathrm{d}\hat{x}'], \y_label = ['\displaystyle \frac{P}{A}', 'GPa'])

Math Text Typesetting:

examples/LaTeX_typesetting/math_text_typesetting.png

LaTeX Typesetting:

Error Bars

Symmetric vertical error bars, and asymmetric horizontal error bars. (Asymmetric error data is input as a two columnnumpy array.) Custom data markers.

import clearplot.plot_functions as pfimport numpy as np

xa = np.arange(0.1, 4, 0.5)

14 Chapter 1. Contents

Page 19: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

ya = 1.5 * np.exp(-xa) - 1.5#Symmetric vertical error barsxa_err = Noneya_err = 0.1 + 0.2*np.sqrt(xa)xb = np.arange(0.01, 3.5, 0.5)yb = 1.5 * np.sin(xb/2)#Asymmetric horizontal error barsxb_err = np.vstack([xb * 0.2 + 0.2, np.ones(xb.shape)*0.4])yb_err = None

[fig, ax, markers] = pf.plot_markers('', [xa, xb], [ya, yb], \x_label = ['\theta','deg'], y_label = ['f(\theta)'], shapes = 'o')

ax.plot_error_bars([xa, xb], [ya, yb], \x_err = [xa_err, xb_err], y_err = [ya_err, yb_err])

fig.save('error_bars.png')

Bar Plot

Bar plot. Symmetric and asymmetric vertical error bars. Legend displayed.

import clearplot.plot_functions as pfimport numpy as np

xa = np.array([1, 2.5, 4, 6])ya = np.arange(4,8,1)ya_err = ya / 10.0xb = np.array([1, 3, 5.5, 7])yb = np.array([2, 4, 3, 5.5])yb_err = np.array([yb / 20.0, yb / 10.0])

1.2. Examples 15

Page 20: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

[fig, ax, bars] = pf.plot_bars('', [xa, xb], [ya, yb], \labels = ['\alpha', '\beta'], x_label = ['N'], y_label = ['d-D'], \widths = 0.75)

ax.plot_error_bars([xa, xb], [ya, yb], y_err = [ya_err, yb_err])fig.save('bar_plot.png')

Box Plot

Box and whiskers plot.

import clearplot.plot_functions as pfimport clearplot as cpimport osimport numpy as npdata_dir = os.path.join(os.path.dirname(os.path.dirname(cp.__file__)), \

'doc', 'source', 'data')

#Verification that box plots work properlypath = os.path.join(data_dir, 'violin_plot_data.csv')data = np.loadtxt(path, delimiter = ',')pf.plot_box_and_whiskers('box_plot.png', \

[np.array([1]), np.array([2]), np.array([3]), np.array([4])], \[data[:,0], data[:,1], data[:,2], data[:,3]], \['\mathsf{Long\;Label}'], ['\varphi','km']);

16 Chapter 1. Contents

Page 21: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

Violin Plot - Custom Tick Labels

Violin plot with custom x-axis tick labels.

import clearplot.figure as figureimport numpy as npimport os

#Load the datadata_dir = os.path.join(os.path.dirname(figure.__file__), os.pardir, 'doc', \

'source', 'data')path = os.path.join(data_dir, 'violin_plot_data.csv')data = np.loadtxt(path, delimiter = ',')

#Plot the datafig = figure.Figure()ax = fig.add_axes()ax.x_label_obj.arrow_bool = Falseax.x_label = ['\mathsf{Categories}']ax.y_label = ['\varphi', 'km']ax.plot_violins([np.array([1]), np.array([2]), np.array([3]), np.array([4])], \

[data[:,0], data[:,1], data[:,2], data[:,3]]);ax.x_tick_list = [1, 2, 3, 4]ax.x_tick_labels = ['a', 'b', 'c', 'd']fig.auto_adjust_layout()fig.save('violin_plot-custom_tick_labels.png')

1.2. Examples 17

Page 22: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

Plot Image and Add Curve

Place an image in the plotting area and add data to the plot afterwards

import clearplot.figure as figureimport os, scipy.miscimport numpy as np

#Load image into pythondata_dir = os.path.join(os.path.dirname(figure.__file__), os.pardir, 'doc', \

'source', 'data')path = os.path.join(data_dir, 'fiber_image.tiff')im = scipy.misc.imread(path)#Specify image positionim_x = np.array([ 2.78977515, 15.43370266])im_y = np.array([ -0.5998, 6.20705447])#Load edge dectection resultspath = os.path.join(data_dir, 'fiber_edge_detection_data.csv')data = np.loadtxt(path, delimiter = ',')

#Place the image on a set of axesfig = figure.Figure()ax = fig.add_axes()im_obj = ax.add_image(im, x = im_x, y = im_y)ax.x_label = ['x', 'mm']ax.y_label = ['y', 'mm']ax.x_tick = 2ax.y_tick = 2ax.x_lim = [0,'auto']ax.y_lim = [-2, 'auto']

18 Chapter 1. Contents

Page 23: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

#Add edge detected dataax.plot(data[:,0], data[:,1])

#Save the data1fig.auto_adjust_layout()fig.save('plot_image_and_add_curve.png')

Intensity Map with a Log Scaled Color Bar

Intensity map (heatmap) plotted as an image. The intensity values are converted to colors using a logarithmicallyscaled color bar.

import clearplot.plot_functions as pfimport numpy as npimport matplotlib.mlab as mlab

#Generate the datadelta = 0.025x = np.arange(-1.5, 1.5 + delta/100, delta)y = np.arange(-1.5, 1.5 + delta/100, delta)xa, ya = np.meshgrid(x, y)r = (xa + 1.5)**2.0 + (ya + 1.5)**2.0z1 = mlab.bivariate_normal(xa, ya, 1.0, 1.0, 0.0, 0.0)z2 = mlab.bivariate_normal(xa, ya, 1.5, 0.5, 1, 1)za = 10.0 ** (5*(z2 - z1))za = za - np.min(za) + 0.01#Plot the matrix as an image

1.2. Examples 19

Page 24: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

pf.plot_intensity_map('intensity_map-log_scale.png', xa, ya, za, \x_label = ['\tau_1', 'kg'], y_label = ['\tau_2', 'kg'], \x_lim = [-1.5, 1.5], y_lim = [-1.5, 1.5], \c_label = ['E', 'kJ'], c_scale = 'log')

Contour Plot

Filled contour plot with colorbar. Options exist to plot only contour lines or to overlay the contour lines over the z dataplotted as an image.

import clearplot.plot_functions as pfimport numpy as npimport matplotlib.mlab as mlab

delta = 0.025x1d = np.arange(-1.5, 1.5 + delta/100, delta)y1d = np.arange(-1.5, 1.5 + delta/100, delta)x, y = np.meshgrid(x1d, y1d)z1 = mlab.bivariate_normal(x, y, 1.0, 1.0, 0.0, 0.0)z2 = mlab.bivariate_normal(x, y, 1.5, 0.5, 1, 1)z = 10.0 * (z2 - z1)

20 Chapter 1. Contents

Page 25: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

pf.plot_contours('contour_plot-filled.png', x, y, z, ['\tau_1', 'kg'], \['\tau_2', 'kg'], x_tick = 0.5, y_tick = 0.5, c_label = ['E', 'kJ']);

Curve and Image Sequence

Image sequence synchronized with a response curve.

import clearplot.plot_functions as pfimport os, scipy.miscimport numpy as np

#Load global responsedata_dir = os.path.join(os.path.dirname(pf.__file__), os.pardir, 'doc', \

'source', 'data')path = os.path.join(data_dir, 's140302C-mechanical_response.csv')data = np.loadtxt(path, delimiter = ',')#Specify the indices of the field images to be plottedndx_list = [0, 85, 141, 196, 252]#Specify the column indices to crop the images tocols = range(470,470+340)

1.2. Examples 21

Page 26: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

#Load the field images into an image sequence listim_seq = []for ndx in ndx_list:

#Load field imageim_filename = 's140302C-eqps_field-frame_%r.png' %(ndx)im_path = os.path.join(data_dir, 'hi-rez_field_images', im_filename)im = scipy.misc.imread(im_path)#Crop the field image and add to listim_seq.append(im[:,cols,:])

#Create labelslabels = []for i in range(1, len(ndx_list) + 1):

labels.append(str(i))

#Plot curve[fig, ax, curves] = pf.plot('', data[:,0], data[:,1], \

x_label = ['\varepsilon', '\%'], y_label = ['\sigma', 'GPa'])ax.label_curve(curves[0], labels, ndx = ndx_list, angles = 60)ax.plot_markers(data[ndx_list,0], data[ndx_list,1], colors = [0,0,0])fig.save('curve_and_image_sequence-a.png');#Plot image sequence[fig, ax, im_obj] = pf.show_im('curve_and_image_sequence-b.png', \

im_seq, scale_im = 0.3, c_label = ['\bar{\varepsilon}^p', '\%'], \c_lim = [0, 100], c_tick = 25, b_labels = True, im_interp = 'bicubic', \c_bar = True);

Curve:

Image Sequence:

22 Chapter 1. Contents

Page 27: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

Video

Generate an animation of the global response synchronized with the field images. The following code should work ona Mac with ffmpeg installed, but it may run into trouble on other platforms.

import scipy.misc, clearplot, osimport numpy as npimport clearplot.figure as figureimport clearplot.plot_functions as pfimport matplotlib.animation as aniimport matplotlib.pyplot as plt

#Load response curvedata_dir = os.path.join(os.path.dirname(clearplot.__file__), os.pardir, 'doc', \

'source', 'data')path = os.path.join(data_dir, 's140302C-mechanical_response.csv')data_a = np.loadtxt(path, delimiter = ',')#Specify the indices of the field images to be plottedndx_list = range(0, 253)#Specify the column indices to crop the image data tocols = range(110, 110+115)#Specify the initial marker locationx_b = np.array([data_a[0,0]])y_b = np.array([data_a[0,1]])#Load the first imageim_filename = os.path.join('lo-rez_field_images', \

's140302C-eqps_field-frame_%r.png' %(1))im_path = os.path.join(data_dir, im_filename)im = scipy.misc.imread(im_path)

#Create figure window (specify in pixels, but convert to mm)fig_size = np.array([680.0, 380.0]) / clearplot.params.dpmmfig = figure.Figure(size = fig_size)#Create mechanical response plot[fig, ax, curves] = pf.plot('', data_a[:,0], data_a[:,1], \

x_label = ['\varepsilon', '\%'], y_label = ['\sigma', 'GPa'], \

1.2. Examples 23

Page 28: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

fig = fig, ax_pos = [35.0, 23.0])ax.plot_markers(x_b, y_b, colors = [1,1,1], edge_widths = [2], sizes = [8])#Create image plot[fig, im_ax, imgs] = pf.show_im('', im[:, cols], scale_im = 1.15, \

c_label = ['\bar{\varepsilon}^p', '\%'], c_lim = [0, 100], c_tick = 25, \c_bar = True, fig = fig, ax_pos = [140.0, 18.0], im_interp = 'bicubic')

#Save the first image of the video (for the website)fig.save('video.png')

#Get the marker and image objects to be updated with each framemarker = ax.markers[0]img = imgs[0]def init():

marker.set_data([], [])img.set_data([[]])return marker, img,

#Define how the figure will be updated with each new framedef update_fig(i):

#Update marker positionmarker.set_data(data_a[2*i,0], data_a[2*i,1])##Load field imageim_filename = os.path.join('lo-rez_field_images', \

's140302C-eqps_field-frame_%r.png' %(2*i+1))im_path = os.path.join(data_dir, im_filename)im = scipy.misc.imread(im_path)#Update imageimg.set_data(im[:,cols])return marker, img,

#Create the animationanim = ani.FuncAnimation(fig.mpl_fig, update_fig, init_func = init, \

frames = int(max(ndx_list)/2), interval = 2)#Specify ffmpeg installation pathplt.rcParams['animation.ffmpeg_path'] = u'/opt/local/bin/ffmpeg'#Save the animationwriter = ani.FFMpegWriter(fps = 15, bitrate = 300)anim.save('video.mp4', writer = writer)

Note: the examples save the figure window as a png by specifying ‘.png’ in the file name. No extension is needed tosave the figure in the default file format (pdf).

clearplot package

Submodules

clearplot.axes module

class Axes(fig, **kwargs)Bases: clearplot.axes._Data_Axes_Base

A generic axes class to plot data on.

__init__(fig, **kwargs)Instantiates a generic axes object to plot data on.

Parameters

24 Chapter 1. Contents

Page 29: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

• fig (figure object) – Figure to place the axes in.

• position (1x2 numpy array, optional) – Position of axes in mm from thelower left corner of the figure.

• size (1x2 numpy array, optional) – Width and height of axes in mm.

• scale_plot (float, optional) – Scales distances between different objects asso-ciated with the axes

• font_size (float, optional) – Font size of text associated with the axes

• share_x_ax (axes object, optional) – Share the x axis with a different set ofaxes to create a plot with two y axes.

• share_y_ax (axes object, optional) – Share the y axis with a different set ofaxes to create a plot with two x axes.

• link_x_ax (axes object, optional) – Link the x axis with a different set ofaxes. The linked x axes will be constrained to have the same limits and tick mark spacings.By default, the new axes will be placed above the original axes.

• link_y_ax (axes object, optional) – Link the y axis with a different set ofaxes. The linked x axes will be constrained to have the same limits and tick mark spacings.By default, the new axes will be placed to the right of the original axes.

add_arrow(style_str, x, cs, orient, length, head_length=7.0, head_aspect_ratio=3.0, color=[0, 0, 0])Creates an arrow with a curved back. The arrow can be placed relative to several coordinate systems, yetit retains it’s shape, even when the data limits, axes, or figure window change size.

Parameters

• x (1x2 numpy array) – Tip of arrowhead, in the coordinate system(s) specified inx_coord_sys

• cs (string or 1x2 list) – Specifies the coordinate system for the coordinates inx. See description of cs_1 in the axes.annotate method for further information.

• orient (float) – Orientation angle (rad) of arrow

• length (float, optional) – Length of the arrow, in mm

• = float, optional (head_length) – Length of the arrowhead

• head_aspect_ratio (float, optional) – Length/width ratio of the arrowhead

• color (1x3 list, optional) – RGB value for the arrow

Returns arrow

Return type annotation object

add_arrowhead(x, cs, orient, length=7.0, aspect_ratio=2.5, color=[0, 0, 0])Creates an arrowhead with a curved back. The arrow can be placed relative to several coordinate systems,yet it retains it’s shape, even when the data limits, axes, or figure window change size.

Parameters

• x (1x2 numpy array) – Tip of arrowhead, in the coordinate system(s) specified inx_coord_sys

• cs (string or 1x2 list) – Specifies the coordinate system for the coordinates inx. See description of cs_1 in the axes.annotate method for further information.

• orient (float) – Orientation angle (rad) of arrowhead

1.3. clearplot package 25

Page 30: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

• length (float, optional) – Length of the arrowhead, in mm

• aspect_ratio (float, optional) – Length/width ratio of the arrowhead

• color (1x3 list, optional) – RGB value for the arrowhead

Returns arrowhead

Return type annotation object

add_arrowheads_to_curves(**kwargs)Adds arrowheads to curves showing the direction of the curves

Parameters

• ndx (list of lists or numpy array, optional) – Specifies the indexalong the curve to place the tip of the arrowhead. If there are M curves and you wantN arrowheads on each curves, input a MxN array of indices.

• length (float, optional) – Arrowhead length from tip to tail

• color (1x3 list, optional) – Arrowhead RGB color

• pick (bool, optional) – Specifies whether or not to manually pick the arrow posi-tions

add_circle(x, r, cs=’axes mm’, **kwargs)Adds a circle to the axes

Parameters

• x (1x2 numpy array) – Coordinates of the circle center. The coordinate system isspecified in cs.

• r (float) – Radius of the circle. The coordinate system is specified in cs.

• cs – Coordinate system for the values in x and r. Valid coordinate system choices include:

– ‘axes mm’ : mm from lower left corner of axes

– ‘data’ : use the axes data coordinate system

• kwargs – Keyword arguments to matplotlib’s Circle class

Returns patch_obj

Return type matplotlib patch object

add_h_line(y, **kwargs)Adds a horizontal line that spans the axes

Parameters

• y (float) – y-coordinate of line

• color (1x3 list, optional) – Color of line. RGB values should be between 0and 1.

• width (float, optional) – Width of line, in points.

• line_style (string, optional) – Style of line. Valid styles include ‘-‘, ‘–‘, ‘-.’,‘:’.

• kwargs – Keyword arguments to matplotlib’s line2D. See the matplotlib documentationfor further details

Returns line

26 Chapter 1. Contents

Page 31: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

Return type line2D instance

add_h_rect(y, **kwargs)Adds a horizontal rectangle that spans the axes

Parameters

• y (1x2 numpy array) – y-coordinates of rectangle’s bottom and top edes

• color (1x3 list, optional) – Color of rectangle. RGB values should be between0 and 1.

• edge_color (1x3 list, optional) – Color of rectangle edges. RGB valuesshould be between 0 and 1.

• edge_width (float, optional) – Width of rectangle edges, in points.

• edge_style (string, optional) – Style of edges. Valid styles include ‘-‘, ‘–‘,‘-.’, ‘:’.

• kwargs – Keyword arguments to matplotlib’s polygon. See the matplotlib documentationfor further details

Returns span

Return type polygon instance

add_image(im, **kwargs)Adds an image to the axes

Parameters clearplot.axes._Data_Axes_Base.add_image() (See) –

add_legend(artists=’auto’, loc=’best’, outside_ax=False, **kwargs)Adds a legend using labels previously associated with artists

Parameters

• artists (list of data objects, optional) – Curves, markers, bars, etc.that will be labeled. Input ‘auto’ to label the artist type specified in artist type.

• loc (string, optional) – Location of legend. Valid options include, ‘best’, ‘upperleft’, ‘upper center, ‘upper right’, ‘center left’, ‘center’, ‘center right’, ‘lower left’, ‘lowercenter’, ‘lower right’.

• outside_ax (bool, optional) – Specifies whether to place the legend outside theaxes.

Returns legend

Return type legend object

add_line(x, **kwargs)Adds a 2D line to the axes

Parameters

• x (Nx2 numpy array) – Coordinates of the line in mm, relative to the axes lower leftcorner. Each row contains a point on the line. Coordinates can be outside the plotting area.

• kwargs – Keyword arguments to matplotlib’s Line2D class

Returns line_obj

Return type matplotlib line object

See also:

1.3. clearplot package 27

Page 32: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

annotate() adds an annotation to the axes

add_text(x, txt, font_size=16.0, **kwargs)Adds text to the axes

Parameters

• x (1x2 numpy array) – Coordinates of the text in mm, relative to the axes lower leftcorner.

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

• font_size (float) – Text font size

• kwargs – Keyword arguments to matplotlib’s text function

Returns txt_obj

Return type text object

See also:

annotate() adds an annotation to the axes

add_title(text, **kwargs)Adds a title above axes.

Parameters

• text (string) – LaTeX formatted string for the title

• kwargs – Keyword arguments to matplotlib’s set_title function. See the matplotlib doc-umentation for further details

add_v_line(x, **kwargs)Adds a vertical line that spans the axes

Parameters

• x (float) – x-coordinate of line

• color (1x3 list, optional) – Color of line. RGB values should be between 0and 1.

• width (float, optional) – Width of line, in points.

• line_style (string, optional) – Style of line. Valid styles include ‘-‘, ‘–‘, ‘-.’,‘:’.

• kwargs – Keyword arguments to matplotlib’s line2D. See the matplotlib documentationfor further details

Returns line

Return type line2D instance

add_v_rect(x, **kwargs)Adds a vertical rectangle that spans the axes

Parameters

• x (1x2 numpy array) – x-coordinates of rectangle’s left and right edges

• color (1x3 list, optional) – Color of rectangle. RGB values should be between0 and 1.

28 Chapter 1. Contents

Page 33: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

• edge_color (1x3 list, optional) – Color of rectangle edges. RGB valuesshould be between 0 and 1.

• edge_width (float, optional) – Width of rectangle edges, in points.

• edge_style (string, optional) – Style of edges. Valid styles include ‘-‘, ‘–‘,‘-.’, ‘:’.

• kwargs – Keyword arguments to matplotlib’s polygon. See the matplotlib documentationfor further details

Returns span

Return type polygon instance

annotate(text, x_1, cs_1, x_2=None, cs_2=[’axes mm’, ‘axes mm’], **kwargs)Adds an annotation to the axes. Annotations can be just text or complex arrows with circled text, dependingon the keyword arguments. This method is essentially a wrapper around matplotlib’s ax.annotate method.

Parameters

• text (string) – Text to add to the axes. Input an empty string (‘’) to omit text.

• x_1 (1x2 numpy array or list) – Coordinates at start of the annotation. Thecoordinate system(s) is specified in cs_1. If text is supplied, it is placed at this location.

• cs_1 (string or list) – Coordinate system(s) for the values in x_1. Input a singlestring to make both coordinates in x_1 use the same coordinate system. Input a 1x2 list tospecify different coordinate systems for each coordinate in x_1. Valid coordinate systemchoices include:

– ‘figure mm’ : mm from the lower left corner of the figure

– ‘figure fraction’ : 0,0 is lower left of figure and 1,1 is upper, right

– ‘axes mm’ : mm from lower left corner of axes

– ‘axes fraction’ : 0,0 is lower left of axes and 1,1 is upper right

– ‘offset mm’ : Specify an offset (in mm) from the x_2 value

– ‘data’ : use the axes data coordinate system

• x_2 (1x2 numpy array, optional) – Coordinates at end of the annotation. Thecoordinate system is specified in cs_2.

• cs_2 (string or list, optional) – Coordinate system for the values in x_2.See description for cs_1 for further information.

• kwargs – Keyword arguments to matplotlib’s annotate function. See the matplotlib doc-umentation for further details

Returns ann_obj

Return type annotation object

See also:

Axes.label_curve() Place multiple labels on a single curve

Axes.label_curves() Place a label on each curve

bboxGets a bounding box for the axes plotting area in mm, relative to the lower left corner of the figure.

1.3. clearplot package 29

Page 34: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

get_obj_bbox(obj)Finds the coordinates of the bounding box surrounding an object, in mm, relative to the lower left cornerof the axes

Parameters obj (graphics primitive object) – object you wish to get the boundingbox for

Returns bbox

Return type bounding box object

label_curve(curve, labels, **kwargs)Prints one or more labels on a single curve, either at interactively picked points or at user specified loca-tions.

Parameters

• curve (curve object) – Curve to label

• labels (list of strings) – Label strings (in LaTeX format)

• style ('normal' or 'balloon', optional) – Input ‘normal’ to create labelswithout circles around them. The default is ‘balloon’ labels, with circles around them.

• Axes.label_curves for descriptions of other inputparameters (See) –

Returns

• If labels have been interactively picked, prints ndx, angles, and

• lengths so the user can input them directly next time.

See also:

Axes.label_curves() Place a label on each curve

label_curves(**kwargs)Labels curves using labels previously associated with curves. Labels are placed either at interactivelypicked points or at user specified locations.

Parameters

• curves (list of curves, optional) – curves to be labeled

• ndx (integer or list of integers, optional) – list of indices that spec-ify the location of the leader line root

• angles (float or list of floats, optional) – list of leader line angles ora single angle (in degrees)

• lengths (float or list of floats, optional) – list of leader line lengthsor a single length (in points)

• pick ('root', 'text', or False, optional) – Input ‘root’ or ‘text’ to in-teractively chose the label positions. If ‘root’ is specified, the user selects the leader lineroot position with the cursor, and specified or default values are used for the leader linelength and angle. If ‘text’ is specified, the user selects the position of the text and theleader line is extended until it intersects the curve at the specified or default angle.

• style ('normal' or 'balloon', optional) – Input ‘balloon’ to create labelswith circles around them. The default is ‘normal’ labels, without circles around them.

• font_size (float, optional) – font size (in points) for label text

30 Chapter 1. Contents

Page 35: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

Returns

• If labels have been interactively picked, prints ndx, angles, and

• lengths so the user can input them directly next time.

See also:

Axes.label_curve() Place multiple labels on a single curve

plot(x, y, labels=[None], **kwargs)Plots x and y data as 2D curves on the axes

Parameters

• x (1xN list of numpy arrays) – x-coordinates of curves

• y (1xN list of numpy arrays) – y-coordinates of curves

• labels (list, optional) – Curve labels (in LaTeX format). (Use add_legend or asimilar command to make the labels visible.)

• curve_colors (list of 1x3 lists, optional) – Colors of curves. RGBvalues should be between 0 and 1.

• curve_styles (list of strings, optional) – Styles of curves. Valid stylesinclude ‘-‘, ‘–‘, ‘-.’, ‘:’.

• curve_widths (list of floats or ints, optional) – Width of curves inpoints.

• marker_shapes (list of strings, optional) – Shapes of markers. See thematplotlib documentation for valid shapes.

• marker_sizes (list of floats or ints, optional) – Sizes of markers,in points.

• marker_colors (list of 1x3 lists, optional) – Colors of marker faces.RGB values should be between 0 and 1.

• marker_edge_widths (list of floats or ints, optional) – Width ofmarker edges in points.

• marker_edge_colors (list of 1x3 lists, optional) – Colors of markeredges. RGB values should be between 0 and 1.

Returns curves

Return type list of curve instances

See also:

Axes.plot_markers() similar to Axes.plot, except it plots markers that can be added to the markerlegend

plot_bars(x, y, labels=[None], **kwargs)Plots x–y data as vertical bars on the axes

Parameters

• x (1xN list of numpy arrays) – x coordinates of bars

• y (1xN list of numpy arrays) – Height of bars

1.3. clearplot package 31

Page 36: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

• labels (list, optional) – Bar labels (in LaTeX format). (Use add_legend or asimilar command to make the labels visible.)

• widths (list of floats or ints, optional) – Width of bars in x-coordinate units

• colors (list of 1x3 lists, optional) – Colors of bars. RGB values shouldbe between 0 and 1.

• edge_styles (list of strings, optional) – Styles of bar edges. Valid op-tions include ‘-‘, ‘–‘, ‘-.’, ‘:’, or ‘None’

• edge_widths (list of floats, optional) – Width of bar edges (in points).

• edge_colors (list of 1x3 lists, optional) – Colors of bar edges. RGBvalues should be between 0 and 1.

• align (['center' | 'edge'], optional) – Specifies which part of the bar toalign to the x coordinate

Returns bars

Return type list of bar instances

plot_box_and_whiskers(x, y, **kwargs)Plot distributions of data in a box and whiskers plot on the axes

Parameters

• x (1xN list of numpy arrays) – x coordinates of boxes

• y (1xN list of numpy arrays) – Distributions of data

• box_widths (list of floats, optional) – Horizontal width of boxes in xdata units

• box_colors (list of 1x3 lists, optional) – Colors of boxes. RGB valuesshould be between 0 and 1.

• box_edge_styles (list of strings, optional) – Styles of box edges.Valid options include ‘-‘, ‘–‘, ‘-.’, ‘:’, or ‘None’

• box_edge_widths (list of floats, optional) – Widths of box edges, inpoints.

• box_edge_colors (list of 1x3 lists of , optional) – Colors of boxedges. RGB values should be between 0 and 1.

• whisker_styles (list of strings, optional) – Styles of whiskers. Validoptions include ‘-‘, ‘–‘, ‘-.’, ‘:’, or ‘None’

• whisker_widths (list of floats, optional) – Widths of whiskers, inpoints.

• whisker_colors (list of 1x3 lists, optional) – Colors of whiskers.RGB values should be between 0 and 1.

• cap_styles (list of strings, optional) – Styles of caps. Valid options in-clude ‘-‘, ‘–‘, ‘-.’, ‘:’, or ‘None’

• cap_widths (list of floats, optional) – Widths of caps, in points.

• cap_colors (list of 1x3 lists, optional) – Colors of caps. RGB valuesshould be between 0 and 1.

32 Chapter 1. Contents

Page 37: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

• flier_shapes (list of strings, optional) – Shapes of fliers. See the mat-plotlib documentation for valid shapes.

• flier_sizes (list of floats, optional) – Size of fliers in points.

• flier_colors (list of 1x3 lists, optional) – Colors of flier faces. RGBvalues should be between 0 and 1.

• flier_edge_widths (list of floats, optional) – Widths of flier edges, inpoints.

• flier_edge_colors (list of 1x3 lists, optional) – Colors of flieredges. RGB values should be between 0 and 1.

See also:

Axes.plot_violins()

plot_contours(x, y, z, **kwargs)Plot three dimensional data as contours on the axes

Parameters

• x (MxN numpy array) – x-coordinates of points

• y (MxN numpy array) – y-coordinates of points

• z (MxN numpy array) – z-coordinates of points. z-coordinates are used to create con-tours.

• plot_type (['filled' | 'intensity map' | 'lines'], optional,default: 'filled') – Type of contour plot. Valid options are:

– filled: the area between two neighboring contour lines is filled in with a single color.

– intensity map: contour lines are overlaid on the z data, which is plotted as an intensitymap. The x and y data must be on a uniform grid. In other words, all the columns ofx must have the same spacing dx, and all the rows of y must have the same spacing dy.(If your data is on an irregular grid, you can always interpolate it onto a uniform grid.)Because a uniform grid is assumed, only the min and max values of x and y are used toplace the intensity map.

– lines: plots only contour lines.

• c_map (string, optional) – Color map for background and contour lines

• c_lim (1x2 list, optional) – Color map limits.

• c_scale (['linear' | 'log'], optional) – Color map scaling

• cl_levels (list of floats, optional) – Contour line levels.

• cl_labels (list of floats, optional) – Contour lines to label.

• cl_label_fsize (float or int, optional) – Contour line labels font size (inpoints).

• cl_label_fmt (string, optional) – Label format string. Ex: ‘%.2f’, ‘%g’, or‘%d’

• cl_width (float or int, optional) – Contour line width (in points).

• cl_style (['_' | '-' | '--' | ':' | None], optional,default: '-') – Contour line style.

• cl_colors (list, optional) – Contour line colors (in RGB format).

1.3. clearplot package 33

Page 38: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

Returns

• b_obj (contourf object, image object, or None) – background object

• cl_obj (contour line object)

See also:

Axes.add_image()

plot_functions.show_imgs() bar

plot_error_bars(x, y, **kwargs)Plots error bars at each x–y data point

Parameters

• x (1xN list of numpy arrays) – x-coordinates of error bar centers

• y (1xN list of numpy arrays) – y-coordinates of error bar centers

• x_err (1xN list of numpy arrays or None objects, optional) – xerror deltas. Supply 1xM numpy array(s) to draw symmetric error bars or 2xM numpyarray(s) to draw assymetric error bars. Supply None object(s) to skip drawing x error barsfor a given data set.

• y_err (1xN list of numpy arrays or None objects, optional) – yerror deltas. Supply 1xM numpy array(s) to draw symmetric error bars or 2xM numpyarray(s) to draw assymetric error bars. Supply None object(s) to skip drawing x error barsfor a given data set.

• colors (list of 1x3 lists, optional) – Colors of error bars. RGB valuesshould be between 0 and 1.

• bar_line_widths (list of floats or ints, optional) – Width of errorbar lines in points.

• cap_line_widths (list of floats or ints, optional) – Width of errorbar cap line widths in points.

• cap_lengths (list of floats or ints, optional) – Length of error barcap in points.

See also:

Axes.plot() similar to Axes.plot_markers, except it plots curves that can be added to the curve legend

Axes.plot_error_bars() plots error bars

plot_intensity_map(x, y, z, **kwargs)Plots a intensity map (heat map) as an image on the axes.

Parameters

• x (1x2 or MxN numpy array) – Matrix x position.

• y (1x2 or MxN numpy array) – Matrix y position.

• z (MxN numpy array) – Matrix to be plotted

• clip_edges (bool, optional) – Specifies whether to clip the extra half pixel alongthe edges of the matrix, so that the edges of the matrix conform to the min and max of xand y.

34 Chapter 1. Contents

Page 39: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

• im_interp (string, optional) – Image interpolation method. See the matplotlibdocumentation for acceptable values.

• c_map (string, optional) – Image color map.

• c_lim (1x2 list, optional) – Color map limits. To automatically chose a limit,input ‘auto’ for either the upper or lower limit.

• c_scale (['linear' | 'log'], optional) – Color scaling.

Returns im_obj

Return type matplotlib image object

See also:

ax.add_image(), ax.add_color_bar(), ax.plot_contours()

Notes

clip_edges causes the edges of the matrix to conform to the min/max of x/y by applying a clipping maskto the image object. The actual edges of the image object still extend beyond the min/max of x/y byhalf a pixel on either side. If the size of the half pixel relative to the tick mark spacing is larger thanthe ax.exceed_lim percentage, then the automatically selected axes limits will extend an extra tick markbeyond the edge of the visible (clipped) data. To avoid this, either specify the x/y limits explicitly, increaseax.exceed_lim, or reduce the size of the pixel relative to the tick mark spacing.

plot_markers(x, y, labels=[None], **kwargs)Plots x and y data as markers on the axes

Parameters

• x (1xN list of numpy arrays) – x-coordinates of markers

• y (1xN list of numpy arrays) – y-coordinates of markers

• labels (list of strings, optional) – Marker labels (in LaTeX format). (Useadd legend or a similar command to make labels visible.)

• shapes (list of strings, optional) – Shapes of markers. See the matplotlibdocumentation for valid shapes.

• sizes (list of floats or ints, optional) – Sizes of markers, in points.

• colors (list of 1x3 lists, optional) – Colors of marker faces. RGB valuesshould be between 0 and 1.

• edge_widths (list of floats or ints, optional) – Width of markeredges in points.

• edge_colors (list of 1x3 lists, optional) – Colors of marker edges.RGB values should be between 0 and 1.

Returns markers

Return type list of marker instances

See also:

Axes.plot() Similar to Axes.plot_markers, except it plots curves that can be added to the curve legend

Axes.plot_error_bars() Plots error bars at each data point

1.3. clearplot package 35

Page 40: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

plot_violins(x, y, **kwargs)Plot distributions of data in a violin plot on the axes

Parameters

• x (1xN list of numpy arrays) – x coordinates of violins

• y (1xN list of numpy arrays) – Distributions of data

• body_widths (list of floats, optional) – Horizontal width of violin bodiesin x data units

• body_colors (list of 1x3 lists, optional) – Colors of violin bodies.RGB values should be between 0 and 1.

• body_edge_styles (list of strings, optional) – Styles of violin bodyedges. Valid options include ‘-‘, ‘–‘, ‘-.’, ‘:’, or ‘None’

• body_edge_widths (list of floats, optional) – Widths of violin bodyedges, in points.

• body_edge_colors (list of 1x3 lists of , optional) – Colors of vio-lin body edges. RGB values should be between 0 and 1.

• show_means (bool, optional) – Show mean of each distribution of data

• show_medians (bool, optional) – Show median of each distribution of data

• show_extrema (bool, optional) – Show extrema of each distribution of data

• line_styles (list of strings, optional) – Styles ofmean/median/extrema edges. Valid options include ‘-‘, ‘–‘, ‘-.’, ‘:’, or ‘None’

• line_widths (list of floats, optional) – Widths of mean/median/extremaedges, in points.

• line_colors (list of 1x3 lists, optional) – Colors ofmean/median/extrema edges. RGB values should be between 0 and 1.

See also:

Axes.plot_box_and_whiskers()

positionGets/sets the position of the axes lower left corner in mm, relative to the lower left corner of the figurewindow.

sizeGet/set the size of the axes. Supply a 1x2 numpy array in mm units to specify a new size.

tight_bboxGets a bounding box in mm that includes the tick marks and tick mark labels, relative to the lower leftcorner of the figure area.

x_labelGets/sets the x axis label. Supply a 1x2 list of strings (in LaTeX syntax) to specify the axis label text andaxis units. The units will automatically be wrapped in paranthesises. Supply a 1x1 list with a single stringto create a label without any units.

x_limGets/sets the x axis limits. Supply a 1x2 list of floats to explicitly set the upper and lower limits. If thestring ‘auto’ is input instead of a float, then the corresponding limit will be automaticaly selected.

36 Chapter 1. Contents

Page 41: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

x_scaleGets/sets the scaling for the x-axis. Valid inputs include ‘linear’ and ‘log’. Note: if you change the scalingwhen the axis limits and ticks are set to ‘auto’ (the default), then the limits and ticks will be recomputed.

x_scale_log_baseGets/sets the logarithmic base for log scaling on the x-axis.

x_tickGets/sets the x axis tick mark spacing. Supply a float to explicitly set the tick marks spacing. If x_tick isset to ‘auto’, then the tick mark spacing will be automatically selected.

x_tick_labelsGets/sets x axis tick labels. Assign a list of strings to set the labels.

x_tick_listGets/sets x-axis tick mark positions. Supply a list of values to explicitly set the tick mark values. Ifx_tick_list is set to ‘auto’, then the tick marks will be automaticaly selected.

x_tick_mmGets/sets the physical distance (in mm) between the tick marks on the x axis. Input a float to specify a newspacing.

y_labelGets/sets the y axis label. Supply a 1x2 list of strings (in LaTeX syntax) to specify the axis label text andaxis units. The units will automatically be wrapped in paranthesises. Supply a 1x1 list with a single stringto create a label without any units.

y_limGets/sets the y axis limits. Supply a 1x2 list of floats to explicitly set the upper and lower limits. If thestring ‘auto’ is input instead of a float, then the corresponding limit will be automaticaly selected.

y_scaleGets/sets the scaling for the y-axis. Valid inputs include ‘linear’ and ‘log’. Note: if you change the scalingwhen the axis limits and ticks are set to ‘auto’ (the default), then the limits and ticks will be recomputed.

y_scale_log_baseGets/sets the logarithmic base for log scaling on the y-axis.

y_tickGets/sets the y axis tick mark spacing. Supply a float to explicitly set the tick marks spacing. If y_tick isset to ‘auto’, then the tick mark spacing will be automatically selected.

y_tick_labelsGets/sets y axis tick labels. Assign a list of strings to set the labels.

y_tick_listGets/sets y-axis tick mark positions. Supply a list of values to explicitly set the tick mark values. Ify_tick_list is set to ‘auto’, then the tick marks will be automaticaly selected.

y_tick_mmGets/sets the physical distance (in mm) between the tick marks on the y axis. Input a float to specify a newspacing.

class Invisible_Axes(fig, **kwargs)Bases: clearplot.axes._Data_Axes_Base

A lightweight set of invisible axes for images, annotations, diagrams, etc.

__init__(fig, **kwargs)Creates a lightweight set of invisible axes.

Parameters

1.3. clearplot package 37

Page 42: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

• fig (figure object) – Figure to place the invisible axes in.

• position (1x2 list or numpy array, optional) – Position of the lowerleft corner of the axes with respect to the lower left corner of the figure (in mm)

• size (1x2 list or numpy array, optional) – Width and height of axes (inmm)

• scale_plot (float, optional) – Scales distances between different objects asso-ciated with the axes

Returns

Return type axes object

add_arrow(style_str, x, cs, orient, length, head_length=7.0, head_aspect_ratio=3.0, color=[0, 0, 0])Creates an arrow with a curved back. The arrow can be placed relative to several coordinate systems, yetit retains it’s shape, even when the data limits, axes, or figure window change size.

Parameters

• x (1x2 numpy array) – Tip of arrowhead, in the coordinate system(s) specified inx_coord_sys

• cs (string or 1x2 list) – Specifies the coordinate system for the coordinates inx. See description of cs_1 in the axes.annotate method for further information.

• orient (float) – Orientation angle (rad) of arrow

• length (float, optional) – Length of the arrow, in mm

• = float, optional (head_length) – Length of the arrowhead

• head_aspect_ratio (float, optional) – Length/width ratio of the arrowhead

• color (1x3 list, optional) – RGB value for the arrow

Returns arrow

Return type annotation object

add_arrowhead(x, cs, orient, length=7.0, aspect_ratio=2.5, color=[0, 0, 0])Creates an arrowhead with a curved back. The arrow can be placed relative to several coordinate systems,yet it retains it’s shape, even when the data limits, axes, or figure window change size.

Parameters

• x (1x2 numpy array) – Tip of arrowhead, in the coordinate system(s) specified inx_coord_sys

• cs (string or 1x2 list) – Specifies the coordinate system for the coordinates inx. See description of cs_1 in the axes.annotate method for further information.

• orient (float) – Orientation angle (rad) of arrowhead

• length (float, optional) – Length of the arrowhead, in mm

• aspect_ratio (float, optional) – Length/width ratio of the arrowhead

• color (1x3 list, optional) – RGB value for the arrowhead

Returns arrowhead

Return type annotation object

add_circle(x, r, cs=’axes mm’, **kwargs)Adds a circle to the axes

38 Chapter 1. Contents

Page 43: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

Parameters

• x (1x2 numpy array) – Coordinates of the circle center. The coordinate system isspecified in cs.

• r (float) – Radius of the circle. The coordinate system is specified in cs.

• cs – Coordinate system for the values in x and r. Valid coordinate system choices include:

– ‘axes mm’ : mm from lower left corner of axes

– ‘data’ : use the axes data coordinate system

• kwargs – Keyword arguments to matplotlib’s Circle class

Returns patch_obj

Return type matplotlib patch object

add_image(im, **kwargs)Adds an image to the current axes

Parameters

• im (MxN or MxNx3 numpy array) – Image to be added to axes

• x (1x2 numpy array, optional) – Image x position.

• y (1x2 numpy array, optional) – Image y position.

• xy_coords (string, optional) – Defines the meaning of x and y coordinates. If‘edges’ is input, then the image edges will correspond to the coordinates in x and y. If‘pixel centers’ is input then the center of the pixels at the image edges will correspond tothe coordinates in x and y.

• im_origin (string, optional) – Origin for the image indices. If ‘upper left’ isinput, then the [0,0] index is the upper left of the image, with positive y being downwards.If ‘lower left’ is input, then the [0,0] index is the lower left of the image, with positive ybeing upwards.

• im_interp (string, optional) – Image interpolation method. See the matplotlibdocumentation for acceptable values.

• c_map (string, optional) – Image color map.

• c_lim (1x2 list, optional) – Color map limits. To automatically chose a limit,input ‘auto’ for either the upper or lower limit.

• c_scale (['linear' | 'log'], optional) – Color scaling.

Returns im_obj

Return type matplotlib image object

See also:

Figure.add_color_bar()

add_line(x, **kwargs)Adds a 2D line to the axes

Parameters

• x (Nx2 numpy array) – Coordinates of the line in mm, relative to the axes lower leftcorner. Each row contains a point on the line. Coordinates can be outside the plotting area.

• kwargs – Keyword arguments to matplotlib’s Line2D class

1.3. clearplot package 39

Page 44: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

Returns line_obj

Return type matplotlib line object

See also:

annotate() adds an annotation to the axes

add_scale_bar(length, text, loc=’lower left’, font_size=16.0)Adds a scale bar just outside of the invisible axes.

Parameters

• length (float) – Length of the scale bar in axis data units

• text (str) – Label that delinates the physical length signified by the scale bar

• loc (['lower left' | 'upper left'], optional) – Scale bar location.ONLY ‘LOWER LEFT’ is implemented at this time.

• font_size (float) – Font size of the text

Returns scale_bar

Return type annotation object

add_text(x, txt, font_size=16.0, **kwargs)Adds text to the axes

Parameters

• x (1x2 numpy array) – Coordinates of the text in mm, relative to the axes lower leftcorner.

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

• font_size (float) – Text font size

• kwargs – Keyword arguments to matplotlib’s text function

Returns txt_obj

Return type text object

See also:

annotate() adds an annotation to the axes

add_title(text, **kwargs)Adds a title above axes.

Parameters

• text (string) – LaTeX formatted string for the title

• kwargs – Keyword arguments to matplotlib’s set_title function. See the matplotlib doc-umentation for further details

annotate(text, x_1, cs_1, x_2=None, cs_2=[’axes mm’, ‘axes mm’], **kwargs)Adds an annotation to the axes. Annotations can be just text or complex arrows with circled text, dependingon the keyword arguments. This method is essentially a wrapper around matplotlib’s ax.annotate method.

Parameters

• text (string) – Text to add to the axes. Input an empty string (‘’) to omit text.

40 Chapter 1. Contents

Page 45: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

• x_1 (1x2 numpy array or list) – Coordinates at start of the annotation. Thecoordinate system(s) is specified in cs_1. If text is supplied, it is placed at this location.

• cs_1 (string or list) – Coordinate system(s) for the values in x_1. Input a singlestring to make both coordinates in x_1 use the same coordinate system. Input a 1x2 list tospecify different coordinate systems for each coordinate in x_1. Valid coordinate systemchoices include:

– ‘figure mm’ : mm from the lower left corner of the figure

– ‘figure fraction’ : 0,0 is lower left of figure and 1,1 is upper, right

– ‘axes mm’ : mm from lower left corner of axes

– ‘axes fraction’ : 0,0 is lower left of axes and 1,1 is upper right

– ‘offset mm’ : Specify an offset (in mm) from the x_2 value

– ‘data’ : use the axes data coordinate system

• x_2 (1x2 numpy array, optional) – Coordinates at end of the annotation. Thecoordinate system is specified in cs_2.

• cs_2 (string or list, optional) – Coordinate system for the values in x_2.See description for cs_1 for further information.

• kwargs – Keyword arguments to matplotlib’s annotate function. See the matplotlib doc-umentation for further details

Returns ann_obj

Return type annotation object

See also:

Axes.label_curve() Place multiple labels on a single curve

Axes.label_curves() Place a label on each curve

bboxGets a bounding box for the axes plotting area in mm, relative to the lower left 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 cornerof the axes

Parameters obj (graphics primitive object) – object you wish to get the boundingbox for

Returns bbox

Return type bounding box object

positionGets/sets the position of the axes lower left corner in mm, relative to the lower left corner of the figurewindow.

sizeGet/set the size of the axes. Supply a 1x2 numpy array in mm units to specify a new size.

tight_bboxGets a bounding box in mm that includes the tick marks and tick mark labels, relative to the lower leftcorner of the figure area.

1.3. clearplot package 41

Page 46: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

x_limGets/sets the x axis limits. Supply a 1x2 list of floats to explicitly set the upper and lower limits.

y_limGets/sets the y axis limits. Supply a 1x2 list of floats to explicitly set the upper and lower limits.

clearplot.axis_label module

class Axis_Label(ax, orient)Bases: object

Axis label class

__init__(ax, orient)Instantiates an axis label object

Parameters

• ax (axes object) – Axes the label pertains to.

• orient (float) – angle in radians specifying the orientation of the axis label (shouldbe 0 for a horizontal axis label or pi/2 for a vertical axis label)

gen_arrow(x, cs, length=’auto’, head_length=’auto’, head_aspect_ratio=3.0, color=[0, 0, 0])Creates an arrow whose head has a curved back. The arrow can be placed relative to several coordinatesystems, yet it retains it’s shape, even when the data limits, axes, or figure window change size.

Parameters

• x (1x2 numpy array) – Coordinates for tip of arrowhead

• cs (string or 1x2 list) – Specifies the coordinate system for the coordinates inx. See the description of cs_1 in the axes.annotate method for more information.

• length (float, optional) – Length of the arrow from tip to tail in mm

• color (1x3 list, optional) – RGB value for the arrow

Returns arrow

Return type annotation object

gen_label(str_list, font_size=16.0)Generates an axis label with or without units in parenthesis

Parameters

• str_list (list of str) – Label text and units in LaTeX syntax.

• font_size (float, optional) – font size (in points)

place_label()Places the axis label

positionSets/gets the axis label position. If the axis label has an arrow, then the position is the arrow tip. Otherwisethe position is the lower left most item in the axis label. Input a 1x2 numpy array, in mm units, to alter theaxis label position.

42 Chapter 1. Contents

Page 47: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

clearplot.color_bar module

class Color_Bar(data_obj, **kwargs)Bases: clearplot.axes._Axes_Base

A color bar class

__init__(data_obj, **kwargs)Instantiates a color bar object

Parameters

• data_obj (data object or a list of data objects) – Image or con-tours that the color bar pertains to

• position (1x2 list or numpy array, optional) – Position of color barlower left corner from the figure lower left corner, in mm.

• ax_2_bar_gap (float, optional) – Gap between axes and color bar, in mm.Only utilized if postion is automatically determined.

• orient (['v', 'h'], optional) – Orientation of the color bar

• tick (float, optional) – Tick mark spacing. If tick is set to ‘auto’, then the tickmark spacing will be automatically selected.

• tick_list (list, optional) – Tick mark positions. If tick_list is set to ‘auto’,then the tick marks will be automaticaly selected.

• tick_labels (list of strings, optional) – Tick mark labels. If tick_labelsis set to ‘auto’, then the tick marks will be automaticaly selected.

• lim (1x2 list, optional) – Lower and upper limits. If the string ‘auto’ is inputinstead of a float, then the corresponding limit will be automaticaly selected.

• scale ([ 'linear' | 'log' ], optional) – Color bar scaling. The default is‘linear’.

add_arrow(style_str, x, cs, orient, length, head_length=7.0, head_aspect_ratio=3.0, color=[0, 0, 0])Creates an arrow with a curved back. The arrow can be placed relative to several coordinate systems, yetit retains it’s shape, even when the data limits, axes, or figure window change size.

Parameters

• x (1x2 numpy array) – Tip of arrowhead, in the coordinate system(s) specified inx_coord_sys

• cs (string or 1x2 list) – Specifies the coordinate system for the coordinates inx. See description of cs_1 in the axes.annotate method for further information.

• orient (float) – Orientation angle (rad) of arrow

• length (float, optional) – Length of the arrow, in mm

• = float, optional (head_length) – Length of the arrowhead

• head_aspect_ratio (float, optional) – Length/width ratio of the arrowhead

• color (1x3 list, optional) – RGB value for the arrow

Returns arrow

Return type annotation object

1.3. clearplot package 43

Page 48: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

add_arrowhead(x, cs, orient, length=7.0, aspect_ratio=2.5, color=[0, 0, 0])Creates an arrowhead with a curved back. The arrow can be placed relative to several coordinate systems,yet it retains it’s shape, even when the data limits, axes, or figure window change size.

Parameters

• x (1x2 numpy array) – Tip of arrowhead, in the coordinate system(s) specified inx_coord_sys

• cs (string or 1x2 list) – Specifies the coordinate system for the coordinates inx. See description of cs_1 in the axes.annotate method for further information.

• orient (float) – Orientation angle (rad) of arrowhead

• length (float, optional) – Length of the arrowhead, in mm

• aspect_ratio (float, optional) – Length/width ratio of the arrowhead

• color (1x3 list, optional) – RGB value for the arrowhead

Returns arrowhead

Return type annotation object

add_circle(x, r, cs=’axes mm’, **kwargs)Adds a circle to the axes

Parameters

• x (1x2 numpy array) – Coordinates of the circle center. The coordinate system isspecified in cs.

• r (float) – Radius of the circle. The coordinate system is specified in cs.

• cs – Coordinate system for the values in x and r. Valid coordinate system choices include:

– ‘axes mm’ : mm from lower left corner of axes

– ‘data’ : use the axes data coordinate system

• kwargs – Keyword arguments to matplotlib’s Circle class

Returns patch_obj

Return type matplotlib patch object

add_line(x, **kwargs)Adds a 2D line to the axes

Parameters

• x (Nx2 numpy array) – Coordinates of the line in mm, relative to the axes lower leftcorner. Each row contains a point on the line. Coordinates can be outside the plotting area.

• kwargs – Keyword arguments to matplotlib’s Line2D class

Returns line_obj

Return type matplotlib line object

See also:

annotate() adds an annotation to the axes

add_text(x, txt, font_size=16.0, **kwargs)Adds text to the axes

44 Chapter 1. Contents

Page 49: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

Parameters

• x (1x2 numpy array) – Coordinates of the text in mm, relative to the axes lower leftcorner.

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

• font_size (float) – Text font size

• kwargs – Keyword arguments to matplotlib’s text function

Returns txt_obj

Return type text object

See also:

annotate() adds an annotation to the axes

annotate(text, x_1, cs_1, x_2=None, cs_2=[’axes mm’, ‘axes mm’], **kwargs)Adds an annotation to the axes. Annotations can be just text or complex arrows with circled text, dependingon the keyword arguments. This method is essentially a wrapper around matplotlib’s ax.annotate method.

Parameters

• text (string) – Text to add to the axes. Input an empty string (‘’) to omit text.

• x_1 (1x2 numpy array or list) – Coordinates at start of the annotation. Thecoordinate system(s) is specified in cs_1. If text is supplied, it is placed at this location.

• cs_1 (string or list) – Coordinate system(s) for the values in x_1. Input a singlestring to make both coordinates in x_1 use the same coordinate system. Input a 1x2 list tospecify different coordinate systems for each coordinate in x_1. Valid coordinate systemchoices include:

– ‘figure mm’ : mm from the lower left corner of the figure

– ‘figure fraction’ : 0,0 is lower left of figure and 1,1 is upper, right

– ‘axes mm’ : mm from lower left corner of axes

– ‘axes fraction’ : 0,0 is lower left of axes and 1,1 is upper right

– ‘offset mm’ : Specify an offset (in mm) from the x_2 value

– ‘data’ : use the axes data coordinate system

• x_2 (1x2 numpy array, optional) – Coordinates at end of the annotation. Thecoordinate system is specified in cs_2.

• cs_2 (string or list, optional) – Coordinate system for the values in x_2.See description for cs_1 for further information.

• kwargs – Keyword arguments to matplotlib’s annotate function. See the matplotlib doc-umentation for further details

Returns ann_obj

Return type annotation object

See also:

Axes.label_curve() Place multiple labels on a single curve

Axes.label_curves() Place a label on each curve

1.3. clearplot package 45

Page 50: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

bboxGets a bounding box for the axes plotting area in mm, relative to the lower left 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 cornerof the axes

Parameters obj (graphics primitive object) – object you wish to get the boundingbox for

Returns bbox

Return type bounding box object

labelSets/gets the color bar label. Supply a 1x2 list of strings (in LaTeX syntax) to specify the axis label textand axis units. The units will automatically be wrapped in paranthesises. Supply a 1x1 list with a singlestring to create a label without any units.

limGets/sets the color bar limits. Supply a 1x2 list of floats to explicitly set the upper and lower limits. If thestring ‘auto’ is input instead of a float, then the corresponding limit will be automaticaly selected.

positionGets/sets the position of the axes lower left corner in mm, relative to the lower left corner of the figurewindow.

scaleGets/sets the scaling for the color bar. Valid inputs include ‘linear’ and ‘log’. Note: if you change thescaling when the axis limits and ticks are set to ‘auto’ (the default), then the limits and ticks will berecomputed.

sizeGet/set the size of the axes. Supply a 1x2 numpy array in mm units to specify a new size.

tickGet/sets the color bar tick mark spacing. Supply a float to explicitly set the tick marks spacing. If tick isset to ‘auto’, then the tick mark spacing will be automatically selected.

tick_labelsGets/sets tick labels. Assign a list of strings to set the labels.

tick_listGets/sets tick mark positions. Supply a list of values to explicitly set the tick mark positions. If tick_list isset to ‘auto’, then the tick marks will be automaticaly selected.

tick_mmGets/sets the physical distance (in mm) between the tick marks. Input a float to specify a new spacing.

tight_bboxGets a bounding box in mm that includes the tick marks and tick mark labels, relative to the lower leftcorner of the figure area.

clearplot.figure module

class Figure(size=’auto’, dpmm=3.1496062992125986)Bases: object

Figure class

46 Chapter 1. Contents

Page 51: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

__init__(size=’auto’, 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 arguments get passed to axes.Axes() (Keyword) –

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.

Other Parameters See parameters in Color_Bar()

add_invisible_axes(**kwargs)Adds a set of invisible axes to the figure.

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

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 firstpoint, 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 thefirst 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

1.3. clearplot package 47

Page 52: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

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 figurewindow and move the content to center all the content inside the window. If the content positions withinthe window have been explicitly specified, then the figure size will be adjusted, but the content positionsrelative 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.

fig_to_mm_transGets a transformation object that converts normalized figure coordinates to mm, relative to the bottom lefthand 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 cornerof the figure window

Parameters obj (graphics primitive object) – object you wish to get the boundingbox for

Returns bbox

Return type bounding box object

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

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

rendererGets the current renderer

Returns renderer

Return type renderer object

48 Chapter 1. Contents

Page 53: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

save(file_name, dpmm=3.1496062992125986, face_color=’w’, edge_color=’w’, transparent=True,bbox=None, pad=0, frame_on=False)

Save the current figure.

Parameters

• file_name (string) – A string containing a path to a filename. If format is None andfilename is a string, the output format is deduced from the extension of the filename. If thefilename 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 patchwill also be transparent unless facecolor and/or edgecolor are specified via kwargs. This isuseful, 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 thisfunction.

• 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 thefigure content. If None, then the figure window will be saved as is.

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

• frame_on (bool) – If True, the figure patch will be colored, if False, the figure back-ground will be transparent. If not provided, the rcParam ‘savefig.frameon’ will be used.

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

tight_bboxGet/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.

clearplot.plot_functions module

plot(filename, x, y, labels=[None], x_label=None, y_label=None, **kwargs)Plot the x and y data as 2D curves.

Parameters

• filename (string) – File name for the plot output file. A file extension supported bymatplotlib, such as ‘.png’, can be appended to the file name to override the default file type.To skip creating an output file, input ‘’ for filename.

• x (list of numpy arrays) – x coordinates of the data to be plotted. Each list elementshould be a 1-D numpy array.

• y (list of numpy arrays) – y coordinates of the data to be plotted. Same structureas the x input.

• labels (list, optional) – Specifies LaTeX strings to label the curves. The listshould be 1xQ, where Q is the number of curves.

1.3. clearplot package 49

Page 54: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

• x_label (list of strings, optional) – x-axis label. The first list element is theaxis variable being plotted, while the second element is the axis units. Both strings shouldbe in LaTeX syntax. The units get automatically wrapped in parentheses. Input a 1x1 list tosupply a variable without any units.

• y_label (list of strings, optional) – y-axis label. The first list element is theaxis variable being plotted, while the second element is the axis units. Both strings shouldbe in LaTeX syntax. The units get automatically wrapped in parentheses. Input a 1x1 list tosupply a variable without any units.

• x_lim (1x2 list, optional) – x-axis limits. The first list element is the lower limit,while the second element is the upper limit. Alternatively, either element may be the string‘auto’ to have the algorithm automatically select the limits.

• y_lim (list, optional) – y-axis limits. The first list element is the lower limit, whilethe second element is the upper limit. Alternatively, either element may be the string ‘auto’to have the algorithm automatically select the limits.

• x_tick (float or int, optional) – Tick mark spacing for the x-axis. Alterna-tively, input ‘auto’ to have the algorithm automatically select the tick mark spacing.

• y_tick (list, optional) – Tick mark spacing for the y-axis. Alternatively, input‘auto’ to have the algorithm automatically select the tick mark spacing.

• x_scale ([ 'linear' | 'log' ], optional) – x-axis scaling. The default is‘linear’.

• y_scale ([ 'linear' | 'log' ], optional) – y-axis scaling. The default is‘linear’.

• legend (bool, optional) – Specifies whether to display a legend for the curves.

• legend_loc (1x2 list or string, optional) – Legend location. For theproper syntax, see the matplotlib documentation for the legend ‘loc’ keyword argument.

• legend_outside_ax (bool, optional) – Specifies whether to place the legendoutside of the data axes. If True then the legend_loc sets the legend position within the axes.If False, then legend_loc sets the legend postion outside the axes.

• legend_kwargs (dict, optional) – Keyword arguments to customize the legendappearance. This is passed directly into the matplotlib legend function. See the matplotlibdocumentation further details.

• scale_plot (float, optional) – Changes the size of the entire plot, but leaves thefont sizes the same.

• font_size (float, optional) – Font size (in points) of the text in the plot.

• fig (figure object, optional) – Figure window to place the plot in. The defaultbehavior is to place the plot in a new, dedicated, figure window.

• ax_pos (1x2 list of floats, optional) – Position (in mm) of the lower leftcorner of the data axes, relative to the lower left corner of the figure window. (For reference,the default distance between tick marks is 20 mm.)

Other Parameters See parameters in Axes.plot()

Returns

• fig (figure object) – Figure object containing the plot.

• ax (axes object) – Axes object containing the data.

• curves (list) – Curve objects

50 Chapter 1. Contents

Page 55: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

See also:

plot_functions.plot_markers()

plot_3d_scatter(filename, x, y, z, x_label=’x’, y_label=’y’, z_label=’z’, x_lim=[’auto’, ‘auto’],y_lim=[’auto’, ‘auto’], z_lim=[’auto’, ‘auto’], x_tick=’auto’, y_tick=’auto’,z_tick=’auto’, light_alt_angle=0.0, light_azm_angle=90.0, title=’None’)

Plots a 3D scatter plot. In development...

plot_bars(filename, x, y, labels=[None], x_label=None, y_label=None, **kwargs)Plot the x and y data as a series of vertical bars

Parameters

• filename (string) – File name for the plot output file. A file extension supported bymatplotlib, such as ‘.jpg’, can be appended to the file name to override the default file type.To skip creating an output file, input ‘’ for filename.

• x (1xN list of numpy arrays) – x coordinates of bars

• y (1xN list of numpy arrays) – Height of bars

• labels (list, optional) – Specifies LaTeX strings to label the curves. The listshould be 1xQ, where Q is the number of curves.

• x_label (list of strings, optional) – x-axis label. The first list element is theaxis variable being plotted, while the second element is the axis units. Both strings shouldbe in LaTeX syntax. The units get automatically wrapped in parentheses. Input a 1x1 list tosupply a variable without any units.

• y_label (list of strings, optional) – y-axis label. The first list element is theaxis variable being plotted, while the second element is the axis units. Both strings shouldbe in LaTeX syntax. The units get automatically wrapped in parentheses. Input a 1x1 list tosupply a variable without any units.

• x_lim (1x2 list, optional) – x-axis limits. The first list element is the lower limit,while the second element is the upper limit. Alternatively, either element may be the string‘auto’ to have the algorithm automatically select the limits.

• y_lim (list, optional) – y-axis limits. The first list element is the lower limit, whilethe second element is the upper limit. Alternatively, either element may be the string ‘auto’to have the algorithm automatically select the limits.

• x_tick (float or int, optional) – Tick mark spacing for the x-axis. Alterna-tively, input ‘auto’ to have the algorithm automatically select the tick mark spacing.

• y_tick (list, optional) – Tick mark spacing for the y-axis. Alternatively, input‘auto’ to have the algorithm automatically select the tick mark spacing.

• x_scale ([ 'linear' | 'log' ], optional) – x-axis scaling. The default is‘linear’.

• y_scale ([ 'linear' | 'log' ], optional) – y-axis scaling. The default is‘linear’.

• legend (bool, optional) – Specifies whether to display a legend for the bars.

• legend_loc (1x2 list or string, optional) – Legend location. For theproper syntax, see the matplotlib documentation for the legend ‘loc’ keyword argument.

• legend_outside_ax (bool, optional) – Specifies whether to place the legendoutside of the data axes. If True then the legend_loc sets the legend position within the axes.If False, then legend_loc sets the legend postion outside the axes.

1.3. clearplot package 51

Page 56: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

• legend_kwargs (dict, optional) – Keyword arguments to customize the legendappearance. This is passed directly into the matplotlib legend function. See the matplotlibdocumentation further details.

• scale_plot (float, optional) – Changes the size of the entire plot, but leaves thefont sizes the same.

• font_size (float, optional) – Font size (in points) of the text in the plot.

• fig (figure object, optional) – Figure window to place the plot in. The defaultbehavior is to place the plot in a new, dedicated, figure window.

• ax_pos (1x2 list of floats, optional) – Position (in mm) of the lower leftcorner of the data axes, relative to the lower left corner of the figure window. (For reference,the default distance between tick marks is 20 mm.)

Other Parameters See parameters in Axes.plot_bars()

Returns

• fig (figure object) – Figure object containing the plot.

• ax (axes object) – Axes object containing the data.

• bars (list) – Bar objects

plot_box_and_whiskers(filename, x, y, x_label=None, y_label=None, **kwargs)Make a box and whisker plot from the x and y data

Parameters

• filename (string) – File name for the plot output file. A file extension supported bymatplotlib, such as ‘.jpg’, can be appended to the file name to override the default file type.To skip creating an output file, input ‘’ for filename.

• x (1xN list of numpy arrays) – x coordinates of boxes

• y (1xN list of numpy arrays) – Distributions of data

• x_label (list of strings, optional) – x-axis label. The first list element is theaxis variable being plotted, while the second element is the axis units. Both strings shouldbe in LaTeX syntax. The units get automatically wrapped in parentheses. Input a 1x1 list tosupply a variable without any units.

• y_label (list of strings, optional) – y-axis label. The first list element is theaxis variable being plotted, while the second element is the axis units. Both strings shouldbe in LaTeX syntax. The units get automatically wrapped in parentheses. Input a 1x1 list tosupply a variable without any units.

• x_lim (1x2 list, optional) – x-axis limits. The first list element is the lower limit,while the second element is the upper limit. Alternatively, either element may be the string‘auto’ to have the algorithm automatically select the limits.

• y_lim (list, optional) – y-axis limits. The first list element is the lower limit, whilethe second element is the upper limit. Alternatively, either element may be the string ‘auto’to have the algorithm automatically select the limits.

• x_tick (float or int, optional) – Tick mark spacing for the x-axis. Alterna-tively, input ‘auto’ to have the algorithm automatically select the tick mark spacing.

• y_tick (list, optional) – Tick mark spacing for the y-axis. Alternatively, input‘auto’ to have the algorithm automatically select the tick mark spacing.

52 Chapter 1. Contents

Page 57: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

• x_scale ([ 'linear' | 'log' ], optional) – x-axis scaling. The default is‘linear’.

• y_scale ([ 'linear' | 'log' ], optional) – y-axis scaling. The default is‘linear’.

• scale_plot (float, optional) – Changes the size of the entire plot, but leaves thefont sizes the same.

• font_size (float, optional) – Font size (in points) of the text in the plot.

• fig (figure object, optional) – Figure window to place the plot in. The defaultbehavior is to place the plot in a new, dedicated, figure window.

• ax_pos (1x2 list of floats, optional) – Position (in mm) of the lower leftcorner of the data axes, relative to the lower left corner of the figure window. (For reference,the default distance between tick marks is 20 mm.)

Other Parameters See parameters in Axes.plot_box_and_whiskers()

Returns

• fig (figure object) – Figure object containing the plot.

• ax (axes object) – Axes object containing the data.

• boxes (list) – Box objects

plot_contours(filename, x, y, z, x_label=None, y_label=None, **kwargs)Create a contour plot from the x, y, and z data.

Parameters

• filename (string) – File name for the plot output file. A file extension supported bymatplotlib, such as ‘.jpg’, can be appended to the file name to override the default file type.To skip creating an output file, input ‘’ for filename.

• x (2-D numpy array) – x coordinates of the data to be plotted.

• y (2-D numpy array) – y coordinates of the data to be plotted. y must have the sameshape as x.

• z (2-D numpy array) – z coordinates of the data to be plotted. z must have the sameshape as x.

• x_label (list of strings, optional) – x-axis label. The first list element is theaxis variable being plotted, while the second element is the axis units. Both strings shouldbe in LaTeX syntax. The units get automatically wrapped in parentheses. Input a 1x1 list tosupply a variable without any units.

• y_label (list of strings, optional) – y-axis label. The first list element is theaxis variable being plotted, while the second element is the axis units. Both strings shouldbe in LaTeX syntax. The units get automatically wrapped in parentheses. Input a 1x1 list tosupply a variable without any units.

• x_lim (1x2 list, optional) – x-axis limits. The first list element is the lower limit,while the second element is the upper limit. Alternatively, either element may be the string‘auto’ to have the algorithm automatically select the limits.

• y_lim (list, optional) – y-axis limits. The first list element is the lower limit, whilethe second element is the upper limit. Alternatively, either element may be the string ‘auto’to have the algorithm automatically select the limits.

1.3. clearplot package 53

Page 58: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

• x_tick (float or int, optional) – Tick mark spacing for the x-axis. Alterna-tively, input ‘auto’ to have the algorithm automatically select the tick mark spacing.

• y_tick (list, optional) – Tick mark spacing for the y-axis. Alternatively, input‘auto’ to have the algorithm automatically select the tick mark spacing.

• c_bar (boolean, optional) – Specifies whether or not to place a color bar in thefigure window.

• c_map (matplotlib colormap object, optional) – If “im” array is MxN,then the array values are mapped to a certain color (or gray value) using the supplied col-ormap.

• c_lim (1x2 list, optional) – Colormap limits. The first element should be thelower limit, while the second element should be the upper limit. Alternatively, either elementmay be the string ‘auto’ to have the algorithm automatically select the limits.

• c_tick (float, optional) – Tick mark spacing for the color bar. Alternatively, inputthe string ‘auto’ to have the algorithm automatically select the tick mark spacing.

• c_orient (the string 'h' or 'v', optional) – Orientation of the color bar.The default is a vertical orientation.

• c_label (list, optional) – Color bar label. The first list element is the color barvariable being plotted, while the second element is the color bar units. Both strings shouldbe in LaTeX syntax. The units get automatically wrapped in parentheses. Input a 1x1 list tosupply a variable without any units.

• c_scale ([ 'linear' | 'log' ], optional) – Color bar scaling. The defaultis ‘linear’.

• scale_plot (float, optional) – Changes the size of the entire plot, but leaves thefont sizes the same.

• font_size (float, optional) – Font size (in points) of the text in the plot.

• fig (figure object, optional) – Figure window to place the plot in. The defaultbehavior is to place the plot in a new, dedicated, figure window.

• ax_pos (1x2 list of floats, optional) – Position (in mm) of the lower leftcorner of the data axes, relative to the lower left corner of the figure window. (For reference,the default distance between tick marks is 20 mm.)

Other Parameters See parameters in Axes.plot_contours()

Returns

• fig (figure object) – Figure object containing the plot.

• ax (axes object) – Axes object containing the data.

• bg (contour background) – Background of contour plot

• cl (contour lines) – Contour lines

plot_intensity_map(filename, x, y, z, x_label=None, y_label=None, **kwargs)Plots a intensity map (heat map) as an image.

Parameters

• filename (string) – File name for the plot output file. A file extension supported bymatplotlib, such as ‘.jpg’, can be appended to the file name to override the default file type.To skip creating an output file, input ‘’ for filename.

• x (1x2 or MxN numpy array) – Matrix x position.

54 Chapter 1. Contents

Page 59: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

• y (1x2 or MxN numpy array) – Matrix y position.

• z (MxN numpy array) – Matrix to be plotted

• x_label (list of strings, optional) – x-axis label. The first list element is theaxis variable being plotted, while the second element is the axis units. Both strings shouldbe in LaTeX syntax. The units get automatically wrapped in parentheses. Input a 1x1 list tosupply a variable without any units.

• y_label (list of strings, optional) – y-axis label. The first list element is theaxis variable being plotted, while the second element is the axis units. Both strings shouldbe in LaTeX syntax. The units get automatically wrapped in parentheses. Input a 1x1 list tosupply a variable without any units.

• x_lim (1x2 list, optional) – x-axis limits. The first list element is the lower limit,while the second element is the upper limit. Alternatively, either element may be the string‘auto’ to have the algorithm automatically select the limits.

• y_lim (list, optional) – y-axis limits. The first list element is the lower limit, whilethe second element is the upper limit. Alternatively, either element may be the string ‘auto’to have the algorithm automatically select the limits.

• x_tick (float or int, optional) – Tick mark spacing for the x-axis. Alterna-tively, input ‘auto’ to have the algorithm automatically select the tick mark spacing.

• y_tick (list, optional) – Tick mark spacing for the y-axis. Alternatively, input‘auto’ to have the algorithm automatically select the tick mark spacing.

• c_bar (boolean, optional) – Specifies whether or not to place a color bar in thefigure window.

• c_map (matplotlib colormap object, optional) – If “im” array is MxN,then the array values are mapped to a certain color (or gray value) using the supplied col-ormap.

• c_lim (1x2 list, optional) – Colormap limits. The first element should be thelower limit, while the second element should be the upper limit. Alternatively, either elementmay be the string ‘auto’ to have the algorithm automatically select the limits.

• c_tick (float, optional) – Tick mark spacing for the color bar. Alternatively, inputthe string ‘auto’ to have the algorithm automatically select the tick mark spacing.

• c_orient (the string 'h' or 'v', optional) – Orientation of the color bar.The default is a vertical orientation.

• c_label (list, optional) – Color bar label. The first list element is the color barvariable being plotted, while the second element is the color bar units. Both strings shouldbe in LaTeX syntax. The units get automatically wrapped in parentheses. Input a 1x1 list tosupply a variable without any units.

• c_scale ([ 'linear' | 'log' ], optional) – Color bar scaling. The defaultis ‘linear’.

• scale_plot (float, optional) – Changes the size of the entire plot, but leaves thefont sizes the same.

• font_size (float, optional) – Font size (in points) of the text in the plot.

• fig (figure object, optional) – Figure window to place the plot in. The defaultbehavior is to place the plot in a new, dedicated, figure window.

1.3. clearplot package 55

Page 60: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

• ax_pos (1x2 list of floats, optional) – Position (in mm) of the lower leftcorner of the data axes, relative to the lower left corner of the figure window. (For reference,the default distance between tick marks is 20 mm.)

Other Parameters See parameters in Axes.plot_matrix()

Returns

• fig (figure object) – Figure object containing the plot.

• ax (axes object) – Axes object containing the data.

• im (image object) – Matrix plotted as an image

plot_markers(filename, x, y, labels=[None], x_label=None, y_label=None, **kwargs)Plot the x and y data as markers (a scatterplot).

Parameters

• filename (string) – File name for the plot output file. A file extension supported bymatplotlib, such as ‘.png’, can be appended to the file name to override the default file type.To skip creating an output file, input ‘’ for filename.

• x (list of numpy arrays) – x coordinates of the data to be plotted. Each list elementshould be a 1-D numpy array.

• y (list of numpy arrays) – y coordinates of the data to be plotted. Same structureas the x input

• labels (list, optional) – Specifies LaTeX strings to label the marker. The listshould be 1xQ, where Q is the number of curves.

• x_label (list of strings, optional) – x-axis label. The first list element is theaxis variable being plotted, while the second element is the axis units. Both strings shouldbe in LaTeX syntax. The units get automatically wrapped in parentheses. Input a 1x1 list tosupply a variable without any units.

• y_label (list of strings, optional) – y-axis label. The first list element is theaxis variable being plotted, while the second element is the axis units. Both strings shouldbe in LaTeX syntax. The units get automatically wrapped in parentheses. Input a 1x1 list tosupply a variable without any units.

• x_lim (1x2 list, optional) – x-axis limits. The first list element is the lower limit,while the second element is the upper limit. Alternatively, either element may be the string‘auto’ to have the algorithm automatically select the limits.

• y_lim (list, optional) – y-axis limits. The first list element is the lower limit, whilethe second element is the upper limit. Alternatively, either element may be the string ‘auto’to have the algorithm automatically select the limits.

• x_tick (float or int, optional) – Tick mark spacing for the x-axis. Alterna-tively, input ‘auto’ to have the algorithm automatically select the tick mark spacing.

• y_tick (list, optional) – Tick mark spacing for the y-axis. Alternatively, input‘auto’ to have the algorithm automatically select the tick mark spacing.

• x_scale ([ 'linear' | 'log' ], optional) – x-axis scaling. The default is‘linear’.

• y_scale ([ 'linear' | 'log' ], optional) – y-axis scaling. The default is‘linear’.

• legend (bool, optional) – Specifies whether to display a legend for the curves.

56 Chapter 1. Contents

Page 61: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

• legend_loc (1x2 list or string, optional) – Legend location. For theproper syntax, see the matplotlib documentation for the legend ‘loc’ keyword argument.

• legend_outside_ax (bool, optional) – Specifies whether to place the legendoutside of the data axes. If True then the legend_loc sets the legend position within the axes.If False, then legend_loc sets the legend postion outside the axes.

• legend_kwargs (dict, optional) – Keyword arguments to customize the legendappearance. This is passed directly into the matplotlib legend function. See the matplotlibdocumentation further details.

• scale_plot (float, optional) – Changes the size of the entire plot, but leaves thefont sizes the same.

• font_size (float, optional) – Font size (in points) of the text in the plot.

• fig (figure object, optional) – Figure window to place the plot in. The defaultbehavior is to place the plot in a new, dedicated, figure window.

• ax_pos (1x2 list of floats, optional) – Position (in mm) of the lower leftcorner of the data axes, relative to the lower left corner of the figure window. (For reference,the default distance between tick marks is 20 mm.)

Other Parameters See parameters in Axes.plot_markers()

Returns

• fig (figure object) – Figure object containing the plot.

• ax (axes object) – Axes object containing the data.

• markers (list) – Marker objects

See also:

plot_functions.plot()

plot_surface(filename, x, y, z, x_label=’x’, y_label=’y’, z_label=’z’, x_lim=[’auto’, ‘auto’],y_lim=[’auto’, ‘auto’], z_lim=[’auto’, ‘auto’], x_tick=’auto’, y_tick=’auto’, z_tick=’auto’,light_alt_angle=0.0, light_azm_angle=90.0, title=’None’)

Plots a 3D surface. In development...

plot_violins(filename, x, y, x_label=None, y_label=None, **kwargs)Make a violin plot from the x and y data

Parameters

• x (1xN list of numpy arrays) – x coordinates of violins

• y (1xN list of numpy arrays) – Distributions of data

• x_label (list of strings, optional) – x-axis label. The first list element is theaxis variable being plotted, while the second element is the axis units. Both strings shouldbe in LaTeX syntax. The units get automatically wrapped in parentheses. Input a 1x1 list tosupply a variable without any units.

• y_label (list of strings, optional) – y-axis label. The first list element is theaxis variable being plotted, while the second element is the axis units. Both strings shouldbe in LaTeX syntax. The units get automatically wrapped in parentheses. Input a 1x1 list tosupply a variable without any units.

• x_lim (1x2 list, optional) – x-axis limits. The first list element is the lower limit,while the second element is the upper limit. Alternatively, either element may be the string‘auto’ to have the algorithm automatically select the limits.

1.3. clearplot package 57

Page 62: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

• y_lim (list, optional) – y-axis limits. The first list element is the lower limit, whilethe second element is the upper limit. Alternatively, either element may be the string ‘auto’to have the algorithm automatically select the limits.

• x_tick (float or int, optional) – Tick mark spacing for the x-axis. Alterna-tively, input ‘auto’ to have the algorithm automatically select the tick mark spacing.

• y_tick (list, optional) – Tick mark spacing for the y-axis. Alternatively, input‘auto’ to have the algorithm automatically select the tick mark spacing.

• x_scale ([ 'linear' | 'log' ], optional) – x-axis scaling. The default is‘linear’.

• y_scale ([ 'linear' | 'log' ], optional) – y-axis scaling. The default is‘linear’.

• scale_plot (float, optional) – Changes the size of the entire plot, but leaves thefont sizes the same.

• font_size (float, optional) – Font size (in points) of the text in the plot.

• fig (figure object, optional) – Figure window to place the plot in. The defaultbehavior is to place the plot in a new, dedicated, figure window.

• ax_pos (1x2 list of floats, optional) – Position (in mm) of the lower leftcorner of the data axes, relative to the lower left corner of the figure window. (For reference,the default distance between tick marks is 20 mm.)

Other Parameters See parameters in Axes.plot_violins()

Returns

• fig (figure object) – Figure object containing the plot.

• ax (axes object) – Axes object containing the data.

• violins (list) – Violin objects

show_im(filename, im_seq, **kwargs)Displays an image or a sequence of images.

Parameters

• filename (string) – File name for the plot output file. A file extension supported bymatplotlib, such as ‘.jpg’, can be appended to the file name to override the default file type.To skip creating an output file, input ‘’ for filename.

• im_seq (list of lists containing MxN or MxNx3 arrays) – A list ofimages sequences. The list should be 1xA, where A is the number of image sequences. Eachimage sequence is a 1xC list, where C is the number of images in the sequence. (Imageswithin a sequence are displayed side by side, while sequences have a small space betweenthem.) Each element in the image sequence list should be a MxN or MxNx3 array. If imageshapes are MxN, the array values are interpreted as intensities that are mapped using thespecified color map. If the shapes are MxNx3, then the array values are treated as RGBvalues.

• scale_im (float, optional) – Scales the images, holding the aspect ratio fixed. Ifleft unspecified the algorithm will attempt to pick the proper value. If the image sequenceis smaller than the screen resolution, then images will be displayed at full scale. Otherwise,the images will be scaled down to fit within the screen resolution.

• scale_gap (float, optional) – Scales the size of the gap between continuous im-age sequences

58 Chapter 1. Contents

Page 63: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

• im_origin (string, optional) – Origin for the image indices. If ‘upper left’ isinput, then the [0,0] index is the upper left of the image, with positive y being downwards.If ‘lower left’ is input, then the [0,0] index is the lower left of the image, with positive ybeing upwards.

• im_interp (string, optional) – Image interpolation method. See matplotlib doc-umentation for acceptable values.

• c_bar (boolean, optional) – Specifies whether or not to place a color bar in thefigure window.

• c_map (matplotlib colormap object, optional) – If “im” array is MxN,then the array values are mapped to a certain color (or gray value) using the supplied col-ormap.

• c_lim (1x2 list, optional) – Colormap limits. The first element should be thelower limit, while the second element should be the upper limit. Alternatively, either elementmay be the string ‘auto’ to have the algorithm automatically select the limits.

• c_tick (float, optional) – Tick mark spacing for the color bar. Alternatively, inputthe string ‘auto’ to have the algorithm automatically select the tick mark spacing.

• c_orient (the string 'h' or 'v', optional) – Orientation of the color bar.The default is a vertical orientation.

• c_label (list, optional) – Color bar label. The first list element is the color barvariable being plotted, while the second element is the color bar units. Both strings shouldbe in LaTeX syntax. The units get automatically wrapped in parentheses. Input a 1x1 list tosupply a variable without any units.

• b_labels (bool, optional) – Specifies whether or not to label images with circlednumbers (balloons)

• scale_plot (float, optional) – Changes the size of the entire plot, but leaves thefont sizes the same.

• font_size (float, optional) – Font size (in points) of the text in the plot.

• fig (figure object, optional) – Figure window to place the plot in. The defaultbehavior is to place the plot in a new, dedicated, figure window.

• ax_pos (1x2 list of floats, optional) – Position (in mm) of the lower leftcorner of the data axes, relative to the lower left corner of the figure window. (For reference,the default distance between tick marks is 20 mm.)

Returns

• fig (figure object) – Figure object containing the plot.

• ax (axes object) – Axes object containing the data.

• im_obj (image object) – Image object containing the image data

See also:

Axes.add_image()

clearplot.utilities module

class Offset_From(artist, ref_pt, units=’mm’)Bases: object

Generates a transformation object to offset from another object

1.3. clearplot package 59

Page 64: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

__init__(artist, ref_pt, units=’mm’)

Parameters

• artist (Artist, Bounding Box, or Transform) – object to offset from

• ref_pt (1x2 list) – Point on the object to offset from. Must be specified in normal-ized bounding box coordinates of the object.

• units ('points', 'pixels', or 'mm') – Units for the offset

get_units()

set_units(units)

adjust_depth(a, proper_depth)Finds the depth of a list or numpy array and adjusts it as necessary

Parameters

• a (list or numpy array) – List or array to be modified

• proper_depth (integer) – Depth that a will be returned with

Returns a – The input a, modified to have the proper depth

Return type list or numpy array

adjust_list_depth(a, proper_depth)Finds the depth of a list and adjusts it as necessary

Parameters

• a (list or any other object) – List to be modified

• proper_depth (integer) – Depth that a will be returned with

Returns a – The input a, modified to have the proper depth

Return type list

convert_err_to_nested_numpy_arrays(g)Finds the bottom of nested lists and converts to N x 2 numpy arrays, as needed.

Parameters a (list) – Nested list of arbitrary depth that may or may not have numpy arrays at thebottom

Returns

• a (list) – Nested list of numpy arrays.

• not_numpy (boolean) – Used during the recurssion process. Not intended for the end user.

cycle_thru_list(list_obj, i)Cycles through a list

Parameters

• list_obj (list) – List to be cycled through

• i (int) – Index of list to be put in the first position

Returns cycled_list – List with index i now in the first position

Return type list

find_and_select_lim_and_tick(ui_lim, ui_tick, data_lim, ax_scale, ax_log_base, exceed_lim)Convenience function that combines find_candidate_lim_and_tick with select_lim_and_tick.

60 Chapter 1. Contents

Page 65: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

find_candidate_lim_and_tick(ui_lim, ui_tick, data_lim, ax_scale, ax_log_base, exceed_lim)Finds candidate limits and tick mark spacings

Parameters

• ui_lim (1x2 list or numpy array) – User input axis limits. Either element canbe set to ‘auto’ to have algorithm automatically select the low or high limit.

• ui_tick (float) – User input tick mark spacing. Set to ‘auto’ to automatically select thetick mark spacing.

• data_lim (1x2 list or numpy array) – Limits of the data on the axis.

• ax_scale (['linear' | 'log']) – Axis scaling.

• ax_log_base (float) – Base of the logarithm for log scaled axes. (Not used for linearlyscaled axes.)

• exceed_lim (float) – When automatically selecting limits, the data is allowed to ex-ceed the limits by this ratio of the tick mark spacing.

Returns

• lim_c (Nx2 list or numpy array) – A list of axis limit candidates

• tick_c (Nx1 list or numpy array) – A list of tick mark spacing candidates.

• n_tick_c (Nx1 list or numpy array) – A list of number of tick marks candidates

find_depth(a)Finds the depth of a list or numpy array using recursion

Parameters a (list or numpy array) – list or array of arbitrary depth

Returns depth – depth of list

Return type integer

find_list_depth(a)Finds the depth of a list using recursion

Parameters a (list) – list of arbitrary depth

Returns depth – depth of list

Return type integer

flatten(a)Flattens list of lists with arbitrary depth into a 1-D list.

Parameters l (list) – list to be flattened

Returns flat_l – flattened list

Return type list

gen_tick_list(ui_tick_list, lim, tick, scale, log_base)Generates a list of tick mark values

Parameters

• ui_tick_list (list or 'auto') – User input list of tick mark values, or ‘auto’ toautomatically generate a tick mark list

• lim (1x2 list or numpy array) – Axis limits.

• tick (float) – Tick mark spacing

1.3. clearplot package 61

Page 66: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

• scale (['log' | 'linear']) – Axis scaling

• log_base (float) – Logarithm base for log scaled axes

Returns tick_list – List of tick mark values

Return type list of floats

get_im_window_extent(im_obj, ax)Gets the bounding box for an image in display (pixel) coordinates

get_unique_rows(array)Finds the unique rows of an array

preprocess_input(ui, depth, C)

raw_string(txt)Python automatically converts escape characters (i.e. n), which causes problems when inputing latex stringssince they are full of backslashes. This function returns a raw string representation of text

Parameters txt (string) – string that possibly contains escape characters

Returns new_text – same as ‘text’ but without any escape characters

Return type string

select_lim_and_tick(lim_c, tick_c, n_tick_c)Select limits and tick mark spacings that give a pleasing number of tick marks

Parameters

• lim_c (Nx2 list or numpy array) – A list of axis limit candidates

• tick_c (Nx1 list or numpy array) – A list of tick mark spacing candidates.

• n_tick_c (Nx1 list or numpy array) – A list of number of tick marks candi-dates

Returns

• lim (1x2 list or numpy array) – Optimum axis limits

• tick (float) – Optimum tick mark spacing

• n_tick_c (float or int) – Optimum number of tick marks

set_im_interp(im_interp, im_obj, ax)Sets the proper image interpolation type for an image.

Parameters

• im_interp (str) – Image interpolation type. If ‘auto’, then algorithm choses either‘nearest’ or ‘none’. If the image is blown up, then it uses ‘nearest’. If the image is scaleddown then it uses ‘none’. See this matplotlib example and this matplotlib example for furtherdetails.

• im_obj (image object) – Image to set the interpolation type on.

• ax (axes object) – Axes containing im_obj

62 Chapter 1. Contents

Page 67: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

Module contents

Version History

version 1.2.0

1. Updated to be compatible with Python 3.

2. Updated to be compatible with matplotlib 2.0.0

3. Modified the color bar class so that multiple images can use the same color bar.

4. Added the ability to plot an intensity map (heat map) as an image.

5. Added the ability to place lines and rectangles that span the axes horizontally or vertically.

6. Added the ability to specify the gap between the color bar and the axes.

7. Fixed a bug where user input axes positions would sometimes work incorrectly if they were specified after axesinstantiation.

8. Fixed bug where user specified labels would be lost in pf.plot_markers() and pf.plot_bars().

9. Fixed the bug so that all sets of markers, instead of just the first set, are output by ax.plot_markers().

version 1.1.0

1. Added the ability to have log scaled color bars.

2. Reorganized the color bar code to minimize code duplication between the initialization method and other meth-ods.

3. Fixed a bug that prevented the color bar from returning the list of tick mark positions.

4. Fixed a bug that caused the color bar label to be placed incorrectly if the color bar size or position were changed.

5. Altered the way users specify labels to artists. Labels are now specified upon artist creation rather than when thelegend is added to the plot. This way the label becomes associated with the artist object, which makes complexlegends with multiple data types much easier.

6. Fixed a bug that caused a duplicate legend to be placed on top of the original legend.

7. Converted the dashed line that marks 0 into a spline instead of a curve. This associates the dashed line morestrongly with the axes. For example, hiding the axes now hides the dashed lines too.

8. Changed the default marker edge width to zero for curves. Now both markers and curves have zero marker edgewidth.

9. Fixed a bug that allowed markers to sometimes appear outside of the plotting area.

10. Fixed a bug with auto-adjusting shared axes. If x/y axis is shared then clearplot attempts to adjust the pair ofy/x axes to make them have the same number of tick marks. If it fails, then it will adjust the physical spacingbetween the tick marks. This should be more robust now.

11. Fixed a bug with picking label text and specifying the leader line angle.

version 1.0.7

1. Changed the default marker edge width to zero.

2. Made figure window only appear on top of all other windows if interactive mode is on.

3. Added a method to the figure class to close the figure window.

4. Fixed a bug that caused fig.auto_adjust_layout() to ignore legends. This bug often caused big legends or legendsplaced outside of the axes to get clipped.

1.4. Version History 63

Page 68: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

5. Changed the latter part of the standard color list to have more distinctive colors. Also automated the process ofcreating dark, darker, and pastel color lists from the standard colors list.

6. Make the tick label e^n non-italic for natural logarithm scaled axes.

7. Fixed a bug where axes would be added to the current figure, even if the user specified a different figure.

version 1.0.6

1. Enabled arbitrary logarithmic bases for log scaled axes.

2. Fixed an incompatibility with circled labels and matplotlib versions prior to 1.5.0.

3. Fixed a bug with setting the physical distance between tick marks before creating axis labels.

4. Fixed a bug with changing the physical distance between tick marks on log axes.

5. Fixed a bug where linked axes did not inherit the physical distance between tick marks.

6. Fixed a bug with determining the unique curves for a legend when the plot has curves with and without markers.

7. Fixed a bug with autoselecting limits with shared axes.

version 1.0.5

1. Switch the matplotlib backend from Qt4Agg to TkAgg, since TkAgg is the only interactive backend that issupposed to work “out of the box” with matplotlib, as of matplotlib version 1.5.0. If you wish to avoid theTkAgg/Spyder figure window size bug detailed here follow the optional additional steps to use the QtAggbackend in Spyder.

version 1.0.4

1. Updated setup.py to install the custom fonts more robustly and to install the color map csv files.

2. Switched to the warnings module instead of simply printing warnings.

version 1.0.3

1. Modified setup.py to automatically install the custom fonts.

2. Moved the color map arrays and the raw data used in the examples into csv files to finish resolving issues ongithub and PyPI.

version 1.0.1 and 1.0.2

1. Hard coded the color map definitions instead of loading them from a pickled file to resolve issues on github andPyPI. Also moved color lists and color maps into a new module called colors.

version 1.0

1. Renamed BRplot to clearplot and made it publicly available for the first time.

BRplot version 3.0

1. Reorganized BRplot from a single python module into a package.

2. Transitioned from documenting BRplot with only docstrings to using Sphinx-doc to generate html documenta-tion.

3. Restructured package to give it an object oriented interface. The functional interface still exists for generat-ing standard plots, but the object oriented interface is helpful for creating custom, specialized, or complicatedplots. The primary changes are the figure object and axes object. When the figure/axes objects is created, italso instantiates a matplotlib figure/axes object inside of it, which is easily accessed by typing fig.mpl_fig /ax.mpl_ax.

64 Chapter 1. Contents

Page 69: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

4. Added the ability to link one x/y axis to another x/y axis in the same figure window so that the axes have thesame limits and tick mark spacing. This allows one to easily stack sets of axes vertically/horizontally in a figurewindow, and keep the x/y axes synchronized.

5. Improved the automatic limit and tick mark selection for plots with multiple x axes or multiple y axes.

6. Added the ability to create violin plots, which provide an easy way to compare several statistical distributions.

7. Switched from the TkAgg backend to the Qt4Agg backend. The Qt4Agg backend seems to let you change thefigure window size at will, while TkAgg acts quite strangely. (For further details, see this post and this post.)

8. Curve legends and marker legends automatically eliminate any duplicate labels.

BRplot version 2.0

1. The function contour() was added to make contour plots.

2. Added the ability to place error bars on data points.

3. The function bar_plot() was added to create bar plots.

4. The function box_plot() was added to create box and whisker plots.

5. Added the ability to place one or more plots in a preexisting figure window.

6. Added an example showing how to use BRplot in a video.

7. Altered the legend keyword arguments to make it easier to place legends. Also, users can now pass any mat-plotlib legend keyword through to the legend method.

8. Added the ability to specify a list of LaTeX strings for tick mark labels.

9. Made pdf the default file type rather than the only file type for saving figures. Now users can input a file namewith a file extension that matplotlib recognizes, and the file will be saved as the file type corresponding to thefile extension.

10. Fixed a bug that caused the placement of axis labels to be off by about 10% of the width and height of the label. InBRplot, axis labels are first placed, then their bounding boxes are measured using the current renderer, and finallythey are moved to the correct location. Unfortunately, BRplot was inadvertently using the wrong renderer whenit measured the text bounding box. Several placement settings were designed around this incorrect renderer, somost of the time things looked just fine. However, the placement settings were unable to compensate for longtext strings, which is what revealed this bug. BRplot should now use the correct renderer, and place axis labelscorrectly. For further information, see this post.

11. It is now possible to turn off the axis arrows.

12. Improved the auto settings for im_plot() and im_show().

13. Improved the organization of the examples and tests.

14. Internal housekeeping: grouped similar variables into dictionaries.

15. Tracked down some confusing behavior when embedding an image in a vector graphics file, such as a pdf. Seethis post for further details. BRplot now tries to select the proper interpolation method based on the size of theimage in the figure window, but the user can override.

BRplot version 1.0

1. Made the figure window appear on top of all other windows instead of behind everything. This turned out to bequite tricky. See this post for further details

2. Took the default values for the keyword arguments out of the function definition line. Now the keyword argu-ments are parsed inside the function. This makes the function definition line much cleaner.

3. The function im_plot() can now display a color bar.

1.4. Version History 65

Page 70: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

4. The function im_show() was added to display a sequence of images.

5. Added the capability to label curves with leader lines. Curves can be labeled interactively, or by specifying theposition of the text and the root of the leader line.

6. The function add_labels() was added to place multiple labels on a single curve.

7. Updated the documentation.

8. Made functions internal to BRplot private. This way, code introspection will first display the functions that usersare meant to employ.

9. If the axes limits could be tighter, but the data will extend very slightly past the limits, the auto limit algorithmwill now select the tighter limits.

10. Changed the input syntax for marker styles, label styles, and line styles so that the user can input either adictionary or individual style attributes.

11. Added the capability to place arrow heads on the curves. Curves can be labeled interactively, or by inputting theposition of the arrow head(s).

12. Changed the default to italic characters for variables and upright characters for units.

13. Changed the default font to TeXGyreHerosTXfonts. This font is a combination of TeXGyreHeros (reduced insize by 10%) for the Latin letters and the math font from the LaTeX txfonts package for the greek letters.

14. Added the proper LaTeX preamble to replicate TeXGyreHerosTXfonts when usetex = True.

15. Converted the examples to an IPython notebook. This makes it easier to see the impact of the various options.

16. Improved y-axis label placement for LaTeX strings whose bounding box extends far below the text baseline.

17. Added some custom colormaps

BRplot Version 0.2

1. Improved PDF bounding box so that it tightly wraps around the limits of the figure content. (Thempl.rcParams[’savefig.bbox’]=’tight’ previously did not work well because BRplot created a set of invisiblefigure axes to place annotations and axis labels in. The bounding box became the edges of the figure axes, eventhough they were invisible. Removing the figure axes also means that PDFs opened in Adobe Illustrator havefewer clipping masks to delete.)

2. Added the ability to input a list of tick marks.

3. If you have clip_on = True in matplotlib, then each curve has it’s own clipping mask, which is really annoyingwhen you just want to select a curve in Adobe Illustrator. In addition, the data outside the clipping mask isvisible once you release the clipping mask. Instead, I switched clip_on = False, and I do the clipping prior toplotting the data.

BRplot Version 0.1

1. Initial testing

2. Added a list of example problems.

66 Chapter 1. Contents

Page 71: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

CHAPTER 2

Primary Features

• Features an object oriented interface for complicated plots and a procedural interface for simple plots. Bothinterfaces are well documented in hyperlinked html.

• Supports linking and stacking multiple sets of axes in a figure. Also supports up to two x and/or y-axes in asingle plot.

• Automatically selects axis limits and tick mark spacings to pleasing values, but user may override.

• Axes labels are automatically offset from axes according to the width and height of the text.

• Curves can be labeled with text and a leader line. Labels can be placed interactively, or by inputting the positionof the text and the root of the leader line.

• Arrow heads can be placed on curves to indicate directionality. Arrow heads can be placed interactively, or byinputting the arrow head position(s).

• Individual axes may be on a linear scale or a log scale.

• Support for bar plots, box and whisker plots, and violin plots.

• Support for several types of contour plots.

• Horizontal and/or vertical error bars can be placed on data points.

• Supports plotting field data as a sequence of images.

• Plots saved as pdfs are designed to be opened and easily edited in Adobe Illustrator or Inkscape.

• Uses a pleasing, easy to read font, TeXGyreHeros-txfonts, which was constructed to match the sans-serif Latinletters and the Greek letters in the txfonts (and newtx) package for LaTeX. This means one can easily use a fontfor plots that matches the font in LaTeX generated equations.

67

Page 72: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

68 Chapter 2. Primary Features

Page 73: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

CHAPTER 3

Bug Fixes

Please submit any bugs you encounter to the Github issue tracker.

69

Page 74: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

70 Chapter 3. Bug Fixes

Page 75: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

CHAPTER 4

Feature Requests and Enhancements

We encourage you to submit your feature requests to the Github issue tracker. We should warn you, however, we canbe quite particular, so please do not take it the wrong way if we do not chose to implement your feature. Similarly,please make sure to submit your feature requests before creating a pull request. It is best to discuss before you codeanything up.

71

Page 76: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

72 Chapter 4. Feature Requests and Enhancements

Page 77: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

CHAPTER 5

Potential Improvements

• When interactively picking curves, highlight the current curve being labeled.

• Setup a check if the kwarg inputs are valid.

• Improve handling of curves that consist of one data point.

• After interactively labeling curves, clearplot prints the label_dict so that it can be easy copied and pasted into ascript. The ‘$’ need to be removed from the latex strings, and the floats should be rounded to only a few digitsbeyond the decimal place.

• Allow label indices to be a 1-D numpy array instead of only a list.

• Load defaults from a file, similar to rcParams.

• Implement more line styles than the limited set that comes with matplotlib

73

Page 78: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

74 Chapter 5. Potential Improvements

Page 79: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Python Module Index

cclearplot, 63clearplot.axes, 24clearplot.axis_label, 42clearplot.color_bar, 43clearplot.figure, 46clearplot.plot_functions, 49clearplot.utilities, 59

75

Page 80: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

76 Python Module Index

Page 81: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Index

Symbols__init__() (Axes method), 24__init__() (Axis_Label method), 42__init__() (Color_Bar method), 43__init__() (Figure method), 46__init__() (Invisible_Axes method), 37__init__() (Offset_From method), 59

Aadd_arrow() (Axes method), 25add_arrow() (Color_Bar method), 43add_arrow() (Invisible_Axes method), 38add_arrowhead() (Axes method), 25add_arrowhead() (Color_Bar method), 43add_arrowhead() (Invisible_Axes method), 38add_arrowheads_to_curves() (Axes method), 26add_axes() (Figure method), 47add_circle() (Axes method), 26add_circle() (Color_Bar method), 44add_circle() (Invisible_Axes method), 38add_color_bar() (Figure method), 47add_h_line() (Axes method), 26add_h_rect() (Axes method), 27add_image() (Axes method), 27add_image() (Invisible_Axes method), 39add_invisible_axes() (Figure method), 47add_legend() (Axes method), 27add_line() (Axes method), 27add_line() (Color_Bar method), 44add_line() (Figure method), 47add_line() (Invisible_Axes method), 39add_polygon() (Figure method), 47add_scale_bar() (Invisible_Axes method), 40add_text() (Axes method), 28add_text() (Color_Bar method), 44add_text() (Figure method), 47add_text() (Invisible_Axes method), 40add_title() (Axes method), 28add_title() (Invisible_Axes method), 40

add_v_line() (Axes method), 28add_v_rect() (Axes method), 28adjust_depth() (in module clearplot.utilities), 60adjust_list_depth() (in module clearplot.utilities), 60annotate() (Axes method), 29annotate() (Color_Bar method), 45annotate() (Invisible_Axes method), 40auto_adjust_layout() (Figure method), 48Axes (class in clearplot.axes), 24Axis_Label (class in clearplot.axis_label), 42

Bbbox (Axes attribute), 29bbox (Color_Bar attribute), 45bbox (Invisible_Axes attribute), 41

Cclearplot (module), 63clearplot.axes (module), 24clearplot.axis_label (module), 42clearplot.color_bar (module), 43clearplot.figure (module), 46clearplot.plot_functions (module), 49clearplot.utilities (module), 59close() (Figure method), 48Color_Bar (class in clearplot.color_bar), 43convert_err_to_nested_numpy_arrays() (in module

clearplot.utilities), 60cycle_thru_list() (in module clearplot.utilities), 60

Ddraw() (Figure method), 48

Ffig_to_mm_trans (Figure attribute), 48Figure (class in clearplot.figure), 46find_and_select_lim_and_tick() (in module

clearplot.utilities), 60

77

Page 82: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

find_candidate_lim_and_tick() (in moduleclearplot.utilities), 60

find_depth() (in module clearplot.utilities), 61find_list_depth() (in module clearplot.utilities), 61flatten() (in module clearplot.utilities), 61

Ggen_arrow() (Axis_Label method), 42gen_label() (Axis_Label method), 42gen_tick_list() (in module clearplot.utilities), 61get_im_window_extent() (in module clearplot.utilities),

62get_obj_bbox() (Axes method), 29get_obj_bbox() (Color_Bar method), 46get_obj_bbox() (Figure method), 48get_obj_bbox() (Invisible_Axes method), 41get_unique_rows() (in module clearplot.utilities), 62get_units() (Offset_From method), 60

IInvisible_Axes (class in clearplot.axes), 37

Llabel (Color_Bar attribute), 46label_curve() (Axes method), 30label_curves() (Axes method), 30lim (Color_Bar attribute), 46

Mmm_to_pix_trans (Figure attribute), 48

OOffset_From (class in clearplot.utilities), 59

Pplace_label() (Axis_Label method), 42plot() (Axes method), 31plot() (in module clearplot.plot_functions), 49plot_3d_scatter() (in module clearplot.plot_functions), 51plot_bars() (Axes method), 31plot_bars() (in module clearplot.plot_functions), 51plot_box_and_whiskers() (Axes method), 32plot_box_and_whiskers() (in module

clearplot.plot_functions), 52plot_contours() (Axes method), 33plot_contours() (in module clearplot.plot_functions), 53plot_error_bars() (Axes method), 34plot_intensity_map() (Axes method), 34plot_intensity_map() (in module

clearplot.plot_functions), 54plot_markers() (Axes method), 35plot_markers() (in module clearplot.plot_functions), 56plot_surface() (in module clearplot.plot_functions), 57

plot_violins() (Axes method), 35plot_violins() (in module clearplot.plot_functions), 57position (Axes attribute), 36position (Axis_Label attribute), 42position (Color_Bar attribute), 46position (Invisible_Axes attribute), 41preprocess_input() (in module clearplot.utilities), 62put_window_on_top() (Figure method), 48

Rraw_string() (in module clearplot.utilities), 62renderer (Figure attribute), 48

Ssave() (Figure method), 48scale (Color_Bar attribute), 46select_lim_and_tick() (in module clearplot.utilities), 62set_im_interp() (in module clearplot.utilities), 62set_units() (Offset_From method), 60show_im() (in module clearplot.plot_functions), 58size (Axes attribute), 36size (Color_Bar attribute), 46size (Figure attribute), 49size (Invisible_Axes attribute), 41

Ttick (Color_Bar attribute), 46tick_labels (Color_Bar attribute), 46tick_list (Color_Bar attribute), 46tick_mm (Color_Bar attribute), 46tight_bbox (Axes attribute), 36tight_bbox (Color_Bar attribute), 46tight_bbox (Figure attribute), 49tight_bbox (Invisible_Axes attribute), 41

Uupdate() (Figure method), 49

Xx_label (Axes attribute), 36x_lim (Axes attribute), 36x_lim (Invisible_Axes attribute), 41x_scale (Axes attribute), 36x_scale_log_base (Axes attribute), 37x_tick (Axes attribute), 37x_tick_labels (Axes attribute), 37x_tick_list (Axes attribute), 37x_tick_mm (Axes attribute), 37

Yy_label (Axes attribute), 37y_lim (Axes attribute), 37y_lim (Invisible_Axes attribute), 42

78 Index

Page 83: Clearplot Documentation - Read the Docs...Clearplot Documentation, Release 1.2.0 Clearplot creates publication quality plots using matplotlib. The project began as an effort to create

Clearplot Documentation, Release 1.2.0

y_scale (Axes attribute), 37y_scale_log_base (Axes attribute), 37y_tick (Axes attribute), 37y_tick_labels (Axes attribute), 37y_tick_list (Axes attribute), 37y_tick_mm (Axes attribute), 37

Index 79