The Plotting Module
- qexpy.plotting.plotting.plot(*args, **kwargs)[source]
Plots a dataset or a function
Adds a dataset or a function to a Plot, and returns the Plot object. This is a wrapper around the matplotlib.pyplot.plot function, so it takes all the keyword arguments that is accepted by the pyplot.plot function, as well as the pyplot.errorbar function.
By default, error bars are not displayed. If you want error bars, it can be turned on in the Plot object.
- Parameters:
*args – The first arguments can be an XYDataSet object, two separate arrays for xdata and ydata, a callable function, or an XYFitResult object. The function also takes a string at the end of the list of arguments as the format string.
- Keyword Arguments:
xdata – a list of data for x-values
xerr – the uncertainties for the x-values
ydata – a list of data for y-values
yerr – the uncertainties for the y-values
xrange (tuple) – a tuple of two values specifying the x-range for the data to plot
xname (str) – the name of the x-values
yname (str) – the name of the y-values
xunit (str) – the unit of the x-values
yunit (str) – the unit of the y-values
fmt (str) – the format string for the object to be plotted (matplotlib style)
color (str) – the color for the object to be plotted
label (str) – the label for the object to be displayed in the legend
**kwargs – additional keyword arguments that matplotlib.pyplot.plot supports
- Return type:
See also
- qexpy.plotting.plotting.hist(*args, **kwargs)[source]
Plots a histogram with a data set
- Parameters:
*args – the ExperimentalValueArray or arguments that creates an ExperimentalValueArray
- Return type:
tuple
See also
- qexpy.plotting.plotting.show(plot_obj=None)[source]
Draws the plot to output
The QExPy plotting module keeps a buffer on the last plot being operated on. If no Plot instance is supplied to this function, the buffered plot will be shown.
- Parameters:
plot_obj (Plot) – the Plot instance to be shown.
- qexpy.plotting.plotting.savefig(filename, plot_obj=None, **kwargs)[source]
Save the plot into a file
The QExPy plotting module keeps a buffer on the last plot being operated on. If no Plot instance is supplied to this function, the buffered plot will be shown.
- Parameters:
filename (string) – name and format of the file (ex: myplot.pdf),
plot_obj (Plot) – the Plot instance to be shown.
The Plot Object
Properties
- Plot.title
The title of this plot, which will appear on top of the figure
- Type:
str
- Plot.xname
The name of the x data, which will appear as x label
- Type:
str
- Plot.yname
The name of the y data, which will appear as y label
- Type:
str
- Plot.xunit
The unit of the x data, which will appear on the x label
- Type:
str
- Plot.yunit
The unit of the y data, which will appear on the y label
- Type:
str
- Plot.xlabel
The xlabel of the plot
- Type:
str
- Plot.ylabel
the ylabel of the plot
- Type:
str
- Plot.xrange
The x-value domain of this plot
- Type:
tuple
Methods
- Plot.fit(*args, **kwargs)[source]
Plots a curve fit to the last data set added to the figure
The fit function finds the last data set or histogram added to the Plot and apply a fit to it. This function takes the same arguments as QExPy fit function, and the same keyword arguments as in the QExPy plot function in configuring how the line of best fit shows up on the plot.