plotting

Content:


The plotting module contains functions based on matplotlib and datafile.

They provide shortcuts to perform typical plotting tasks in experimental physics.

NOTE: when you use these functions, enter the show() command to see the result interactively.

Example::
>>> import LT.plotting as P
>>> import numpy as np
>>> x = np.array([1.,2.,3.,4.,5])
>>> y = x**2
>>> P.plot_line(x, y)
>>> P.pl.show() # or just show() if you used: ipython -pylab

LT.plotting.plot_exp(x, y, dy=[], dyt=[], marker='.', linestyle='None', label='_nolegend_', ecolor_1='black', elinewidth=2, capsize=4, mew=2, linewidth=2, logy=False, min_val=None, scale=1.0, x_label=None, y_label=None, plot_title=None, skip_labels=False, axes=None, **kwargs)

Plot experimental data using a linear scale by default. Below are a few examples

(it is assumed that the module as been imported as import LT.plotting as P:

>>> P.plot_exp(x, y)             # plot data points only, no errobars
>>> P.plot_exp(x, y, sig_y)      # plot data points including errors stored in sig_y
>>> P.plot_exp(x, y, dy=sig_y)   # alternatively using key word dy
>>> P.plot_exp(x, y, dy=sig_y, dyt = sig_y_tot) # plot two errorbars, sig_y_tot = total error
>>> P.plot_exp(x, y, dy=sig_y, xerr = sig_x) # plot also x errorbars, values stored in sig_x

Important keywords:

Keyword

Meaning

dy

array with errors

dyt

array with additional error values (e.g. total errors)

marker

marker type (see plot())

linestyle

line style (see plot())

logy

use log y-scale (True/False)

label

label for data (used in legend() )

min_val

min. values to be plotted

scale

scale ally-values (including errrors ) by this factor

x_label

label for x-axis

y_label

label for y-axis

plot_title

plot title

skip_labels

do no put any labels (True/False)

There are more key words, but ususally you do not need to change them and you should be familiar with matplotlib before you do so. Keywords which are not listed here are passed along on to plot(), or errorbar() routines.


LT.plotting.plot_line(x, y, label='_nolegend_', logy=False, convx=1.0, convy=1.0, axes=None, **kwargs)

Plot a line through a set of data point using a linear scale by default. Below are a few examples. This is mostly used to plot a calculated curve.

(it is assumed that the module as been imported as import LT.plotting as P:

>>> P.plot_line(x, y)             # x and y are :func:`numpy.array`

Important keywords:

Keyword

Meaning

label

label for curve (used in legend() )

logy

use log y-scale (True/False)

convx

scale all x-values by this factor

convy

scale all y-values by this factor

Additional keywords are passed along to the plot() command.


LT.plotting.plot_spline(x, y, marker='None', min_val=5e-12, label='_nolegend_', nstep=5, conv=1.0, convx=1.0, convy=1.0, logy=False, axes=None, **kwargs)

Plot a line through a set of data point using a linear scale by default. Below are a few examples. This is mostly used to plot a calculated curve.

(it is assumed that the module as been imported as import LT.plotting as P:

>>> P.plot_line(x, y)             # x and y are numpy arrays

Important keywords:

Keyword

Meaning

label

label for curve (used in legend() )

logy

use log y-scale (True/False)

nstep

factor by which the number of interpolated data points is increased

convx

scale all x-values by this factor

convy

scale all y-values by this factor

Additional keywords are passed along to the plot() command.


LT.plotting.datafile_plot_exp(set, x='x', y='y', dy=None, dyt=None, linestyle='None', marker='.', label='_nolegend_', ecolor_1='black', elinewidth=2, capsize=4, mew=2, linewidth=2, logy=False, min_val=None, scale=1.0, x_label=None, y_label=None, plot_title=None, skip_labels=False, axes=None, **kwargs)

Plot experimental data from a datafile using the variable names defined there.

(it is assumed that the module as been imported as import LT.plotting as P:

>>> P.datafile_plot_exp(df, x='xv', y='yv') 
>>> P.datafile_plot_exp(df, x='xv', y='yv', dy = 'sigy')          
>>> P.datafile_plot_exp(df, x='xv', y='yv' ,dy='sigy', dyt = 'sigyt') 

df is the datafile object, opened with dfile() or LT.get_data()

NOTE: errors in x-axis are not implemented here.

Important keywords:

Keyword

Meaning

x

variable name for x-axis data

y

variable name for y-axis data

dy

variable name for errors

dyt

variable name with additional error values (e.g. total errors)

marker

marker type (see plot())

linestyle

line style (see plot())

label

label for data (used in legend() )

logy

use log y-scale (True/False)

min_val

min. values to be plotted

scale

scale all y-values (including errrors ) by this factor

x_label

label for x-axis

y_label

label for y-axis

plot_title

plot title

skip_labels

do no put any labels (True/False)

There are more key words, but ususally you do not need to change them and you should be familiar with matplotlib before you do so. Keywords which are not listed here are passed along on to plot(), or errorbar() routines.


LT.plotting.datafile_plot_theory(set, x='x', y='y', marker='None', min_val=5e-12, color='b', label='_nolegend_', convx=1.0, convy=1.0, logy=False, axes=None, **kwargs)

Plot a line through data using the variable names and datafile object directly. Keywords similar to plot_line()


LT.plotting.datafile_spline_plot_theory(set, x='x', y='y', marker='None', min_val=5e-12, color='b', label='_nolegend_', nstep=5, convx=1.0, convy=1.0, logy=False, axes=None, **kwargs)

Plot a spline through data using the variable names and datafile object directly. Keywords similar to plot_spline()


LT.plotting.dplot_exp(*args, **kwargs)

see LT.plotting.datafile_plot_exp()


LT.plotting.dplot_line(*args, **kwargs)

see LT.plotting.datafile_plot_theory()


LT.plotting.dplot_spline(*args, **kwargs)

see LT.plotting.datafile_spline_plot_theory()