unidec.modules.plotting package¶
Submodules¶
unidec.modules.plotting.ColorPlot module¶
- class unidec.modules.plotting.ColorPlot.ColorPlot2D(*args, **kwargs)¶
Bases:
PlottingWindowBase
Method to perform a 3D plot by plotting the Z axis as 2D slices of a different color. Each 2D slice uses the alpha (trasparency) parameter to indicate intensity in square root scale.
- make_color_plot(mzgrid, mzax, dtax, ztab)¶
Creates the color plot :param mzgrid: mz x dt x z numpy array of intensity values :param mzax: m/z axis :param dtax: drift time axis :param ztab: charge axis :return: None
- make_compare_color_plot(data1, data2, test_kda=True, xlab='', ylab='')¶
unidec.modules.plotting.NoZoomSpan module¶
- class unidec.modules.plotting.NoZoomSpan.NoZoomSpan(axes, onselect, parent=None, minspan=None, useblit=False, rectprops=None, zoombutton=None, onmove_callback=None)¶
Bases:
ZoomCommon
Expansion of matplotlib embed in wx example by John Bender and Edward Abraham, see https://www.scipy.org/Matplotlib_figure_in_a_wx_panel
This version allows the user to zoom in on the figure using either a span selector or a box selector. You can also set a persistent span selector that acts as cursor references on top of whatever is plotted
ZoomSpan based on matplotlib.widgets.SpanSelector CursorSpan based on matplotlib.widgets.SpanSelector BoxZoom based on matplotlib.widgets.RectangleSelector
Brian J. Soher, Duke University, 20 October, 2010
Select a min/max range of the x or y axes for a matplotlib Axes
Example usage:
axes = subplot(111) axes.plot(x,y)
- def onselect(vmin, vmax):
print vmin, vmax
span = ZoomSpan(axes, onselect, ‘horizontal’)
onmove_callback is an optional callback that will be called on mouse move with the span range
- ignore(event)¶
return True if event should be ignored
- new_axes(axes)¶
- onmove(event)¶
- press(event)¶
on button press event
- release(event)¶
on button release event
- update()¶
draw using newfangled blit or oldfangled draw depending on useblit
- update_background(event)¶
force an update of the background
unidec.modules.plotting.PlotAnimations module¶
- class unidec.modules.plotting.PlotAnimations.AnimationWindow(parent, data_list, config=None, yvals=None, mode='1D', pks=None, pksmode='mz', *args, **kwargs)¶
Bases:
Frame
- add_peaks(e=None)¶
- add_peaks_mass(e=None)¶
- add_peaks_mz(e=None)¶
- init()¶
Create a fresh plot and start the animation. :return: None
- on_back(e)¶
Plot the previous data set in data_list. :param e: Unused event :return: None
- on_close(e)¶
Stop the animation and close the window. :param e: Unused event :return: None
- on_next(e)¶
Plot the next data set in data_list. :param e: Unused event :return: None
- on_play(e)¶
Toggles self.play on or off. Will break the while loop in self.update if self.play = False. :param e: Unused event :return: None
- on_save_fig(e=None)¶
- refresh_plot()¶
Create a fresh plot from the top. :return: None
- save_fig(base, ext)¶
- update(frame_number)¶
Continues to increment the plot to the next value in the data_list. Will stop if self.play is False. :param frame_number: Required but unused. Filled by FuncAnimation. :return: 0
- update_framerate(e)¶
Change the frame rate. Restart the animation with fresh frame rate. :param e: Unused event :return: None
- update_plot()¶
Increment to the next data set and update the plot with the new data. Tries to keep some of the old plotting parameters like the zoom the same. Stops the animation if an error occurs. :return: None
unidec.modules.plotting.PlotBase module¶
- class unidec.modules.plotting.PlotBase.PlotBase(*args, **kwargs)¶
Bases:
object
Class for matplotlib plots
- add_legend(location=1, anchor=None)¶
Adds a legend to the plot. :param location: Integer code for location :param anchor: BBox to anchor parameter :return: None
- add_rect(xstart, ystart, xwidth, ywidth, alpha=0.5, facecolor='k', edgecolor='k', nopaint=False)¶
- add_title(title='')¶
- addtext(txt, x, y, vlines=True, hlines=False, color='k', ymin=0, ymax=None, verticalalignment='top', xmin=0, xmax=None, nopaint=False, **kwargs)¶
Adds text and lines. Puts things that have been added in self.lines and self.text lists. :param txt: String of text to add :param x: x position for where to add :param y: y position for where to add :param vlines: Whether to add vertical lines to the text as well. :param hlines: Whether to add horizontal lines to the text as well. :param color: Color of text and lines :param ymin: Minimum value of vlines :param ymax: Maximum value of vlines :param verticalalignment: Vertical alignment of the text :param xmin: Minimum value of hlines :param xmax: Maximum value of hlines :param nopaint: Don’t paint it :param kwargs: Keywords If range=(a,b) is specified, adds a line from a to b and vertical lines at a and b. :return: None
- clear_plot(*args)¶
Clear the plot and rest some of the parameters. :param args: Arguments :return:
- draw_mz_curve(sarray, color='y', alpha=0.4, adduct_mass=1, repaint=False)¶
- get_blank_axis(scale=None)¶
- get_limits()¶
- get_linewidth()¶
- get_png()¶
Returns PNG string of figure. :return: PNG string
- get_svg()¶
Returns SVG string of figure. :return: SVG string
- get_zoomvals()¶
- kda_test(xvals)¶
Test whether the axis should be normalized to convert mass units from Da to kDa. Will use kDa if: xvals[int(len(xvals) / 2)] > 100000 or xvals[len(xvals) - 1] > 1000000
If kDa is used, self.kda=True and self.kdnorm=1000. Otherwise, self.kda=False and self.kdnorm=1. :param xvals: mass axis :return: None
- on_save_fig(evt, path, **kwargs)¶
Save figure to path. :param evt: wx.Event (unused) :param path: Path to save figure to :param kwargs: keywords passed to save_figure :return: None
- plotadddot(x, y, colval, markval, label='', linewidth=None)¶
Adds a scatter plot to the figure. May be one or more. :param x: x values :param y: y values :param colval: Color :param markval: Marker :param label: Label for Plot :param linewidth: Line width :return: None
- repaint(setupzoom=False, resetzoom=False)¶
- reset_zoom()¶
- save_figure(path, **kwargs)¶
Saves Figure to path. :param path: Path to save figure at. :param kwargs: Keywords passed to matplotlib.figure.savefig (note only specific ones are passed) :return: None
- set_aspect(aspect=None)¶
- set_color(rgbtuple=None)¶
Sets background color :param rgbtuple: background color :return:
- set_nticks(bins)¶
Set the number of ticks in the x-axis. :param bins: Number of ticks in the x-axis :return: None
- set_tickcolor()¶
Sets tick colors based on the colormap set at self.cmap :return: None
- set_zoomvals(zoomvals=None)¶
- setup_zoom(plots=None, zoom=None, data_lims=None, pad=0, groups=None)¶
- textremove()¶
Remove text and lines previous placed in the self.text and self.lines containers :return: None
- update_style(stylefile=None)¶
- write_data(path)¶
- zoomout()¶
unidec.modules.plotting.PlottingWindow module¶
- class unidec.modules.plotting.PlottingWindow.MZLimitsEvent(evttype, id, minval=None, maxval=None)¶
Bases:
PyCommandEvent
- class unidec.modules.plotting.PlottingWindow.NetworkFrame(*args, **kwargs)¶
Bases:
PlottingWindowBase
- clear_frame()¶
- class unidec.modules.plotting.PlottingWindow.Plot1d(*args, **kwargs)¶
Bases:
PlottingWindowBase
,Plot1dBase
Class for 1D plots.
- class unidec.modules.plotting.PlottingWindow.Plot2d(*args, **kwargs)¶
Bases:
PlottingWindowBase
,Plot2dBase
Plotting class for 2D contour plots
- class unidec.modules.plotting.PlottingWindow.PlotAny(*args, **kwargs)¶
Bases:
PlottingWindowBase
,Plot1dBase
,Plot2dBase
Plotting class for 2D contour plots
- class unidec.modules.plotting.PlottingWindow.PlottingWindowBase(*args, **kwargs)¶
Bases:
PlotBase
,Panel
Class for wx window with embedded matplotlib plots Inherits from PlotBase, which is the core functions stripped of everything interactive
- copy_to_clipboard(*args, **kwargs)¶
- mouse_activate(event)¶
- mouse_inactivate(event)¶
- on_draw(event)¶
- on_idle(event)¶
Function triggered on idle event from plot. :param event: wx.Event :return: None
- on_key(evt)¶
- on_left_click(x, y)¶
- on_newxy(x, y)¶
- on_release(event)¶
Function triggered on button release event from plot. Currently wired to trigger on_save_figure_dialog on middle button. :param event: wx.Event :return: None
- on_right_click(event=None)¶
- on_save_fig(evt, path, **kwargs)¶
Save figure to path. :param evt: wx.Event (unused) :param path: Path to save figure to :param kwargs: keywords passed to save_figure :return: None
- on_save_fig_dialog(evt)¶
Open a save figure dialog for specified plot. :param evt: wx.Event (unused) :return: None
- on_scans_selected(smin, smax)¶
- on_size(event)¶
Resizes the plots :param event: wx.Event :return: None
- on_swoop_drag(sarray)¶
- on_write_dialog(evt)¶
Open a save figure dialog for specified plot. :param evt: wx.Event (unused) :return: None
- repaint(setupzoom=True, resetzoom=False)¶
Redraw and refresh the plot. :param setupzoom: Boolean, whether to setup zooming :param resetzoom: Boolean, whether to reset zooming :return: None
- set_resize(newsize)¶
- setup_zoom(plots, zoom, data_lims=None, pad=0, groups=None)¶
Set up zoom on axes. :param pad: Padding around plot :param plots: Axes objects to setup :param zoom: Type of zoom (‘span’ or ‘box’) :param data_lims: Optional manual description of the data limits (where to go when fully zoomed out) :param groups: Group of axes to link zoom together for :return: None
- size_handler(event=None, *args, **kwargs)¶
Resizes the plots :param args: :param kwargs: :return: None
- zoomout()¶
- class unidec.modules.plotting.PlottingWindow.ScanSelectedEvent(evttype, id, smin=None, smax=None)¶
Bases:
PyCommandEvent
- class unidec.modules.plotting.PlottingWindow.SwoopDragEvent(evttype, id, sarray=None)¶
Bases:
PyCommandEvent
unidec.modules.plotting.ZoomBox module¶
- class unidec.modules.plotting.ZoomBox.ZoomBox(axes, onselect, parent=None, groups=None, drawtype='box', minspanx=None, minspany=None, useblit=False, lineprops=None, rectprops=None, onmove_callback=None, spancoords='data', button=None, data_lims=None, swoop=False, integrate=0, smash=0, pad=0.0001)¶
Bases:
ZoomCommon
Select a min/max range of the x axes for a matplotlib Axes
Example usage:
from matplotlib.widgets import RectangleSelector from pylab import * def onselect(xmin, xmax, value, ymin, ymax): 'eclick and erelease are matplotlib events at press and release' print ' x,y min position : (%f, %f)' % (xmin, ymin) print ' x,y max position : (%f, %f)' % (xmax, ymax) print ' used button : ', eclick.button def toggle_selector(event): print ' Key pressed.' if event.key in ['Q', 'q'] and toggle_selector.RS.active: print ' RectangleSelector deactivated.' toggle_selector.RS.set_active(False) if event.key in ['A', 'a'] and not toggle_selector.RS.active: print ' RectangleSelector activated.' toggle_selector.RS.set_active(True) x = arange(100)/(99.0) y = sin(x) fig = figure axes = subplot(111) axes.plot(x,y) toggle_selector.RS = ZoomBox(axes, onselect, drawtype='line') connect('key_press_event', toggle_selector) show()
- ignore(event)¶
return True if event should be ignored
- initialize()¶
- new_axes(axes, rectprops=None)¶
- onmove(event)¶
- press(event)¶
on button press event
- release(event)¶
on button release event
- set_clipping()¶
- update()¶
draw using newfangled blit or oldfangled draw depending on useblit
- zoomout(event=None)¶
unidec.modules.plotting.ZoomCommon module¶
- unidec.modules.plotting.ZoomCommon.GetMaxes(axes, xmin=None, xmax=None)¶
- unidec.modules.plotting.ZoomCommon.GetStart(axes)¶
- unidec.modules.plotting.ZoomCommon.ResetVisible(axes)¶
- class unidec.modules.plotting.ZoomCommon.ZoomCommon¶
Bases:
object
- get_active()¶
to get status of active mode (boolean variable)
- kill_labels()¶
- label()¶
- left_click(x, y)¶
- on_newxy(x, y)¶
- peakdetect(data, window=10.0, threshold=0.0)¶
- right_click(event=None)¶
- scans_selected(vmin, vmax)¶
- set_active(active)¶
Use this to activate / deactivate the RectangleSelector
from your program with an boolean variable ‘active’.
- set_auto_ylim(xmin, xmax, draw=True)¶
- set_manual(xmin, xmax)¶
- set_manual_y(ymin, ymax)¶
- set_xlim(xmin, xmax, draw=True)¶
- set_ylim(ymin, ymax, draw=True)¶
- switch_label()¶
- update_background(event)¶
force an update of the background
- unidec.modules.plotting.ZoomCommon.clip_all(axes)¶
- unidec.modules.plotting.ZoomCommon.clip_none(axes)¶
- unidec.modules.plotting.ZoomCommon.set_clipping(axes)¶
- unidec.modules.plotting.ZoomCommon.special_clip(axes)¶
unidec.modules.plotting.ZoomSpan module¶
- class unidec.modules.plotting.ZoomSpan.ZoomSpan(axes, onselect, parent=None, minspan=None, useblit=False, rectprops=None, onmove_callback=None)¶
Bases:
ZoomCommon
Expansion of matplotlib embed in wx example by John Bender and Edward Abraham, see https://www.scipy.org/Matplotlib_figure_in_a_wx_panel
This version allows the user to zoom in on the figure using either a span selector or a box selector. You can also set a persistent span selector that acts as cursor references on top of whatever is plotted
ZoomSpan based on matplotlib.widgets.SpanSelector CursorSpan based on matplotlib.widgets.SpanSelector BoxZoom based on matplotlib.widgets.RectangleSelector
Brian J. Soher, Duke University, 20 October, 2010
Select a min/max range of the x or y axes for a matplotlib Axes
Example usage:
axes = subplot(111) axes.plot(x,y)
- def onselect(vmin, vmax):
print vmin, vmax
span = ZoomSpan(axes, onselect, ‘horizontal’)
onmove_callback is an optional callback that will be called on mouse move with the span range
- ignore(event)¶
return True if event should be ignored
- new_axes(axes)¶
- onmove(event)¶
- press(event)¶
on button press event
- release(event)¶
on button release event
- update()¶
draw using newfangled blit or oldfangled draw depending on useblit
- zoomout(event=None)¶
unidec.modules.plotting.plateplot module¶
- class unidec.modules.plotting.plateplot.PlateFrame(parent)¶
Bases:
Frame
- change_type(e=None)¶
- draw()¶
- load_eng(eng)¶
- make_plot(data=None)¶
- onmove(e=None)¶
- replot(e=None)¶
- class unidec.modules.plotting.plateplot.PlatePlot(*args, **kwargs)¶
Bases:
PlottingWindowBase
Plotting class for 3D Waterfall plots.
- make_plate(type=96)¶
- onmove(e=None)¶
- populate(positions, colors=None)¶
- unidec.modules.plotting.plateplot.cc(arg)¶
unidec.modules.plotting.plot1d module¶
- class unidec.modules.plotting.plot1d.Plot1dBase(*args, **kwargs)¶
Bases:
PlotBase
- add_centroid(centroids, color=None, repaint=True)¶
Add a centroid line to the plot. :param centroids: Centroid array :param color: Color :param repaint: Boolean, whether to repaint or not :return: None
- barplottop(xarr, yarr, peakval, colortab, xlabel='', ylabel='', title='', zoom='box', repaint=True)¶
Create a bar plot. :param xarr: x value array :param yarr: y value array :param peakval: Bar labels to be listed below bars :param colortab: List of colors for the various bars :param xlabel: Label for x axis :param ylabel: Label for y axis :param title: Plot title :param zoom: Type of zoom (‘box’ or ‘span) :param repaint: Boolean, whether to repaint or not when done. :return: None
- barplottoperrors(xarr, yarr, peakval, colortab, xlabel='', ylabel='', title='', zoom='box', repaint=True, xerr=0, yerr=0)¶
Create a bar plot. :param xarr: x value array :param yarr: y value array :param peakval: Bar labels to be listed below bars :param colortab: List of colors for the various bars :param xlabel: Label for x axis :param ylabel: Label for y axis :param title: Plot title :param zoom: Type of zoom (‘box’ or ‘span) :param repaint: Boolean, whether to repaint or not when done. :param xerr: for error bars :param yerr: for error bars :return: None
- centroid_plot(centroids, color=None, xlabel='m/z', ylabel='', title='', zoom='box', repaint=True)¶
Create a centroid line plot. :param xarr: x value array :param yarr: y value array :param color: List of colors for the various dots :param xlabel: Label for x axis :param ylabel: Label for y axis :param title: Plot title :param zoom: Type of zoom (‘box’ or ‘span) :param repaint: Boolean, whether to repaint or not when done. :return: None
- colorplotMD(xvals, yvals, cvals, title='', xlabel='', ylabel='', clabel='Mass Defect', cmap='hsv', config=None, color='black', max=1, marker=None, zoom='box', nopaint=False, test_kda=False, integerticks=False, **kwargs)¶
- errorbars(xvals, yvals, xerr=None, yerr=None, color='black', newlabel='', nopaint=True, **kwargs)¶
- filledplot(x, y, color='black')¶
Creates a plot filled between the y values and the y axis :param x: x values :param y: y values :param color: color :return: None
- histogram(xarray, labels=None, xlab='', ylab='', title='')¶
Creates a histogram plot. :param xarray: Array of values in (N x M) array :param labels: Labels for value :param xlab: x axis label :param ylab: y axis label :param title: Plot Title :return: None
- insetplot(x, y, a, b)¶
- multiplot(x, y, a, b)¶
- plotadd(xvals, yvals, colval='black', newlabel='', nopaint=True, **kwargs)¶
Adds a plot. :param xvals: x values :param yvals: y values :param colval: Color :param newlabel: Label :param nopaint: Boolean, whether to repaint or not :return: None
- plotrefreshtop(xvals, yvals, title='', xlabel='', ylabel='', label='', config=None, color='black', marker=None, zoom='box', nopaint=False, test_kda=False, integerticks=False, zoomout=False, **kwargs)¶
Create a new 1D plot. :param xvals: x values :param yvals: y values :param title: Plot title :param xlabel: x axis label :param ylabel: y axis label :param label: label for legend :param config: UniDecConfig object :param color: Plot color :param marker: Marker type :param zoom: zoom type (‘box’ or ‘span’) :param nopaint: Boolean, whether to repaint or not :param test_kda: Boolean, whether to attempt to plot kDa rather than Da :param integerticks: Boolean, whether to use inter tickmarks only :param zoomout: Boolean, whether to zoom out :param kwargs: Keywords :return: None
- scatterplottop(xarr, yarr, color=None, xlabel='', ylabel='', title='', zoom='box', repaint=True)¶
Create a bar plot. :param xarr: x value array :param yarr: y value array :param color: List of colors for the various dots :param xlabel: Label for x axis :param ylabel: Label for y axis :param title: Plot title :param zoom: Type of zoom (‘box’ or ‘span) :param repaint: Boolean, whether to repaint or not when done. :return: None
unidec.modules.plotting.plot2d module¶
- class unidec.modules.plotting.plot2d.Plot2dBase(*args, **kwargs)¶
Bases:
PlotBase
Plotting class for 2D contour plots
- contourplot(dat=None, config=None, xvals=None, yvals=None, zgrid=None, xlab='m/z (Th)', ylab='Charge', title='', normflag=1, normrange=None, repaint=True, nticks=None, test_kda=False, discrete=None, ticloc=None, ticlab=None, order=None)¶
Make 2D plot.
- Data can be added using two methods:
If dat is specified, it will look for an N x 3 list of x,y,z values
If xvals, yvals, and zgrid are filled, it will plot zgrid assuming its shape is (len(xvals),len(yvals))
- Parameters:
dat – N x 3 list in [x,y,z] format of data to be plotted
config – UniDecConfig object
xvals – x-axis values
yvals – y-axis values
zgrid – numpy array of shape (len(xvals),len(yvals))
xlab – Label for x-axis
ylab – Label for y-axis
title – Plot title
normflag – Set to 1 to normalize the plot range from min to max. If 0, will not normalize.
normrange – Range to normalize to if normflag is 0.
repaint – If true, will repaint the plot after it is done.
nticks – Number of ticks on the x-axis. If None, will use default.
test_kda – If true, will decide if the x-axis is better displayed in Da or kDa units.
- Returns:
None
- hist2d(xvals, yvals, bins, config=None, xlab='m/z (Th)', ylab='Charge', title='', repaint=True, nticks=None, test_kda=False)¶
- plot_native_z(offset, col, xvals, width=0, alpha=1, shape=0)¶
Plots a showing the native charge offsets. :param offset: Offset value :param col: Color :param xvals: x-axis (mass) :param width: Width of charge distribution. :param alpha: Transparency of plot overlay :param shape: Indicates whether the width defines a step function of a Gaussian distribution :return: None
unidec.modules.plotting.plot3d module¶
- class unidec.modules.plotting.plot3d.CubePlot(*args, **kwargs)¶
Bases:
PlottingWindowBase
Plotting class for cube plots. Performs isometric projections of three 2D plots onto three faces of a cube.
- cubeplot(xaxis, yaxis, zaxis, C, C2, C3, xlab='', ylab='', zlab='', cmap='jet')¶
Make 2D isometric projection plot of three cube faces :param xaxis: X-axis values :param yaxis: Y-axis values :param zaxis: Z-axis values :param C: Intensity grid for X v. Y face :param C2: Intensity grid for X v. Z face :param C3: Intensity grid for Y v. Z face :param xlab: X-axis label :param ylab: Y-axis label :param zlab: Z-axis label :param cmap: Colormap for 2D plot :return: None
- isogrids()¶
Sets jsometric projections of X, Y, and Z axis grids :return: None
- isolabels(xticlab, yticlab, zticlab, ax, col)¶
Draw isometric projection of axis labels :param xticlab: X-axis label (string) :param yticlab: Y-axis label (string) :param zticlab: Z-axis label (string) :param ax: Axis object :param col: Color (not presently used) :return: None
- isolines()¶
Draw isometric projection of lines at the edge of the cube. :return: None
- isometric_projection(x, y, z)¶
Give the isometric projection of a given (x,y,z) onto a plane set by self.alpha and self.beta :param x: x value (float) :param y: y value (float) :param z: z value (float) :return: o, isometric projection vector
- isoticks(ax, col)¶
Draws isometric projection of tick marks. :param ax: Axis object :param col: Color of ticks :return: None
- make_isomatrices()¶
Make projection matrix, self.pc, for calculating isometric projection :return: None
unidec.modules.plotting.plot_waterfall module¶
- class unidec.modules.plotting.plot_waterfall.Waterfall3DPlot(*args, **kwargs)¶
Bases:
PlottingWindowBase
Plotting class for 3D Waterfall plots.
- get_angle()¶
- onmove(e=None)¶
- set_angle(elevation, azimuth)¶
- waterfall(xgrid, ygrid, zarray, colors=None, xlabel='Mass', ylabel='')¶
- class unidec.modules.plotting.plot_waterfall.WaterfallFrame(parent)¶
Bases:
Frame
- change(e=None)¶
- change_type(e=None)¶
- draw()¶
- make_plot(data=None)¶
- onmove(e=None)¶
- unidec.modules.plotting.plot_waterfall.cc(arg)¶