pyspecdata.plot_funcs package¶
Submodules¶
pyspecdata.plot_funcs.DCCT_function module¶
Domain Colored Coherence Transfer (DCCT) function allows us to visualize the complex-valued data, as well as the formalization of the coherence transfer dimensions using domain coloring plotting.
- pyspecdata.plot_funcs.DCCT_function.DCCT(this_nddata, fig=None, custom_scaling=False, bbox=[0.05, 0.1, 0.9, 0.8], gap=0.1, horiz_label_spacer=35, shareaxis=False, diagnostic=False, cmap=None, pass_frq_slice=False, scaling_factor=1, max_coh_jump={'ph1': 1, 'ph2': 2}, direct='t2', title=None, arrow_dx=30, arrow_dy=30, **kwargs)¶
DCCT plot.
- Parameters:
this_nddata (nddata) – data being plotted
fig (figure) – size/type of figure to be plotted on
custom_scaling (boolean) – allows user to scale the intensity of data presented
bbox (matplotlib.girdspec.SubplotSpec) –
contains the following: :bbox[0]: int
Left hand side padding between the left side of the figure and the left side of the decorations.
- bbox[1]:
int Distance between the bottom of the figure and the bottom of the lowest axes object (in Figure coordinates)
- bbox[2]:
int Distance between the right most side of the axes objects and the left most side of the decorations (in Figure coordinates)
- bbox[3]:
int Distance from bottom of the bottom axes object to top of top axes object
bbox – If you specify a gridspec element, it will use this to generate a bbox, as above.
gap (float) – Figure coordinates Spacing between coherence transfer pathways
horiz_label_spacer (int) – Display coordinates Spacing between vertical lines that label the coherence pathways
shareaxis (boolean) – Subplots scale together, but currently, this means there must be tick labels on both top and bottom
diagnostic (boolean) – Option to additionally display diagnostic plots
cmap (str) – Color mapping if specified
pass_frq_slice (boolean) – If true will show the frequency sliced out with hatching
scaling_factor (float) – If using custom scaling this allows user to set the scaling factor
max_coh_jump (dict) – Maximum allowed transitions for each phase cycle
direct (str) – Name of direct axis
title (str) – Title for DCCT plot
- Returns:
ax_list (list) – list of axes objects generated in DCCT plot
transform_dict (dict) – dictionary containing the unique transforms generated in this function for scaled translations
- pyspecdata.plot_funcs.DCCT_function.decorate_axes(my_data, idx, remaining_dim, depth, a_shape, ax_list, ordered_labels, label_placed, horiz_label_spacer, arrow_dx, arrow_dy, fig, transDispTranslated, transXdispYfig)¶
This function is called recursively to decorate the axes
- pyspecdata.plot_funcs.DCCT_function.fl_DCCT(self, this_nddata, **kwargs)¶
- pyspecdata.plot_funcs.DCCT_function.majorLocator()¶
- pyspecdata.plot_funcs.DCCT_function.minorLocator()¶
- pyspecdata.plot_funcs.DCCT_function.place_labels(my_data, ax1, label, label_placed, this_label_num, horiz_label_spacer, arrow_dx, arrow_dy, fig, transDispTranslated, pos_from_tick=False, arrow_width_px=4.0)¶
Place arrows and dimname labels
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.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, cmap='viridis', shading='nearest', ax1=None, ax2=None, ax=None, scale_independently=False, vmin=None, vmax=None, human_units=True, force_balanced_cmap=False, handle_axis_sharing=True, mappable_list=None)¶
generate a pcolormesh and label it with the axis coordinate available from the nddata
- Parameters:
fig (matplotlib figure object) –
cmap (str (default 'viridis')) – cmap to pass to matplotlib pcolormesh
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?
ax (matplotlib axes object) – if passed, this is just used for ax1
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 []) –
used to scale multiple plots along the same color axis. Used to make all 3x2 plots under a uniform color scale.
List of QuadMesh objects returned by this function.
- 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.