pyspecdata.plot_funcs package

Submodules

pyspecdata.plot_funcs.image module

pyspecdata.plot_funcs.image.fl_image(self, A, **kwargs)

Called as fl.image() where fl is the figlist_var object

Note that this code just wraps the figlist properties, and the heavy lifting is done by the image( function. Together, the effect is as follows:

  • check_units converts to human-readable units, and makes sure they match the units already used in the plot.

  • if A has more than two dimensions, the final dimension in A.dimlabels is used as the column dimension, and a direct-product of all non-column dimensions (a Kronecker product, such that the innermost index comes the latest in the list A.dimlabels) is used as the row dimension. A white/black line is drawn after the innermost index used to create the direct product is finished iterating.

  • If A consists of complex data, then an HSV plot (misnomer, actually an HV plot) is used: - convert to polar form: \(z=\rho \exp(i \phi)\) - \(\phi\) determines the color (Hue)

    • Color wheel is cyclical, like \(\exp(i \phi)\)

    • red is taken as \(\phi=0\), purely real and positive

    • green-blue is \(pi\) radians out of phase with red and therefore negative real

    • \(\rho\) determines the intensity (value) - Depending on whether or not black is set (either as a

      keyword argument, or fl.black, the background will be black with high \(\rho\) values “lit up” (intended for screen plotting) or the background will be white with the high \(\rho\) values “colored in” (intended for printing)

  • If the data type (dtype) of the data in A is real (typically achieved by calling abs(A) or A.runcopy(real)), then A is plotted with a colormap and corresponding colorbar.

  • If no title has been given, it’s set to the name of the current plot in the figurelist

pyspecdata.plot_funcs.image.A
Type:

nddata or numpy array

pyspecdata.plot_funcs.image.x

If A is a numpy array, then this gives the values along the x axis (columns). Defaults to the size of the array. Not used if A is nddata.

Type:

Optional[double] or Optional[scalar]

pyspecdata.plot_funcs.image.y

If A is a numpy array, then this gives the values along the y axis (columns). Defaults to the size of the array. Not used if A is nddata.

Type:

Optional[double] or Optional[scalar]

pyspecdata.plot_funcs.image.x_first

Since it’s designed to represent matrices, an image plot by defaults is “transposed” relative to all other plots. If you want the first dimension on the x-axis (e.g., if you are plotting a contour plot on top of an image), then set x_first to True.

Type:

boolean

pyspecdata.plot_funcs.image.spacing

Determines the size of the white/black line drawn Defaults to 1

Type:

integer

pyspecdata.plot_funcs.image.ax

the Axis object where the plot should go.

Type:

matplotlib Axes

all remaning

are passed through to matplotlib imshow

pyspecdata.plot_funcs.image.origin

upper and lower are passed to matplotlib. Flip is for 2D nmr, and flips the data manually.

Type:

{‘upper’, ‘lower’, ‘flip’}

.. code-block:: python

from pyspecdata import * fl = figlist_var()

t = r_[-1:1:300j] x = nddata(t,[-1],[‘x’]).labels(‘x’,t) y = nddata(t,[-1],[‘y’]).labels(‘y’,t)

z = x**2 + 2*y**2 print “dimlabels of z:”,z.dimlabels

fl.next(‘image with contours’) fl.image(z,x_first = True) # x_first is needed to align # with the contour plot z.contour(colors = ‘w’,alpha = 0.75)

fl.next(‘simple plot’) # just to show that x is the same # here as well fl.plot(z[‘y’:(0,0.01)])

fl.show(‘compare_image_contour_150911.pdf’)

pyspecdata.plot_funcs.image.image(A, x=[], y=[], allow_nonuniform=True, **kwargs)

Please don’t call image directly anymore – use the image method of figurelist

pyspecdata.plot_funcs.image.imagehsv(A, logscale=False, black=False, scaling=None)

This provides the HSV mapping used to plot complex number

pyspecdata.plot_funcs.pcolormesh module

pyspecdata.plot_funcs.pcolormesh.pcolormesh(self, fig=None, shading='nearest', ax1=None, ax2=None, ax=None, scale_independently=False, human_units=True, force_balanced_cmap=False, handle_axis_sharing=True, mappable_list=[])

generate a pcolormesh and label it with the axis coordinate available from the nddata

Parameters:
  • fig (matplotlib figure object) –

  • shading (str (default 'nearest')) – the type of shading to pass to matplotlib pcolormesh

  • ax1 (matplotlib axes object) – where do you want the left plot to go?

  • ax2 (matplotlib axes object) – where do you want the right plot to go?

  • scale_independently (boolean (default False)) – Do you want each plot to be scaled independently? (If false, the colorbar will have the same limits for all plots)

  • handle_axis_sharing (boolean (default True)) – Typically, you want the axes to scale together when you zoom – e.g. especially when you are plotting a real and imaginary together. So, this defaults to true to do that. But sometimes, you want to get fancy and, e.g. bind the sharing of many plots together because matplotlib doesn’t let you call sharex/sharey more than once, you need then to tell it not to handle the axis sharing, and to it yourself outside this routine.

  • mappable_list (list, default []) – empty list which fills with field values from color axis used for initial subplot, used to scale multiple plots along the same color axis. Used to make all 3x2 plots under a uniform color scale

Returns:

mappable_list – list of field values for scaling color axis, used to make all 3x2 plots under a uniform color scale

Return type:

list

Module contents

This subpackage contains plotting functions that take advantage of nddata. Eventually, all plotting functions should be moved to separate modules in this subpackage.