pwem.viewers.plotter module

class pwem.viewers.plotter.EmPlotter(x=1, y=1, mainTitle='', **kwargs)[source]

Bases: Plotter

Class to create several plots.

This Plotter class has some utilities to create a Matplotlib figure and add some plots to it. Params:

x, y: number of rows and columns of the grid for plots. mainTitle: figure main title. figsize: the size of the figure, if None, it will be guessed from x and y dpi: resolution, 100 by default. windowTitle: title for the whole windows.

classmethod createFromFile(dbName, dbPreffix, plotType, columnsStr, colorsStr, linesStr, markersStr, xcolumn, ylabel, xlabel, title, bins, orderColumn, orderDirection)[source]
plotAngularDistribution(title, rot, tilt, weight=[], max_p=40, min_p=5, color='blue', colormap=None, subtitle=None)[source]

Create a special type of subplot, representing the angular distribution in 2d of weighted projections.

plotAngularDistribution3D(title, x, y, z, weights, subtitle, colormap=<matplotlib.colors.LinearSegmentedColormap object>)[source]
plotAngularDistributionBase(data, eulerAnglesGetterCallback, title, type=2, colormap=<matplotlib.colors.LinearSegmentedColormap object>, subtitle='', **kwargs)[source]

Read the values of the transformation matrix and plot its histogram or its angular distribution.

Parameters
  • colormap – matplotlib color map

  • data – any particles iterator containing particles with alignment information. sqlites or star files , …

  • eulerAnglesGetterCallback – a callback to extract rot, tilt, psi IN DEGREES from each row, receiving the row/item.

  • title – Title of the plot.

  • type – 1 for histogram, 2 for polar plot, 3 for 3d plot

  • subtitle – subtitle of the plot

plotAngularDistributionFromMd(mdFile, title, **kwargs)[source]

Read the values of rot, tilt and weights from the metadata and plot the angular distribution. ANGLES are in DEGREES In the metadata:

rot: MDL_ANGLE_ROT tilt: MDL_ANGLE_TILT weight: MDL_WEIGHT

plotAngularDistributionFromSet(mdSet, title, type=2, colormap=<matplotlib.colors.LinearSegmentedColormap object>, subtitle='', **kwargs)[source]

Read the values of the transformation matrix and plot its histogram or its angular distribution.

Parameters
  • type – Type of plot 1=histogram, 2=2D polar, 3=3D

  • mdSet – Set with alignment information at with item.getTransform()

  • title – Title of the plot

  • colormap – matplotlib color map

plotAngularDistributionHistogram(title, data, eulerAnglesGetterCallback, colormap=<matplotlib.colors.LinearSegmentedColormap object>, subtitle=None)[source]

Create a special type of subplot, representing the angular distribution of projections.

plotData(xValues, yValues, color='blue', **kwargs)[source]

Shortcut function to plot some values. Params:

xValues: list of values to show in x-axis yValues: list of values to show as values in y-axis color: color for the plot. **kwargs: keyword arguments that accepts:

marker, linestyle

plotDataBar(xValues, yValues, width, color='blue', **kwargs)[source]

Shortcut function to plot some values. Params:

xValues: list of values to show in x-axis yValues: list of values to show as values in y-axis color: color for the plot. **kwargs: keyword arguments that accepts:

marker, linestyle

plotHist(yValues, nbins, color='blue', **kwargs)[source]

Create a histogram.

plotMatrix(img, matrix, vminData, vmaxData, cmap='jet', xticksLablesMajor=None, yticksLablesMajor=None, rotationX=90.0, rotationY=0.0, **kwargs)[source]
plotScatter(xValues, yValues, color='blue', **kwargs)[source]

Create a scatter plot.

scatter3DPlot(x, y, z, title='3D scatter plot', drawsphere=True, markerSize=1, colormap=<matplotlib.colors.LinearSegmentedColormap object>, subtitle=None)[source]
weightEulerAngles(rots, tilts, delta=3, rotInRadians=False)[source]

Receives the list of rots and tilts angles (in deg) and returns a reduced list of rots, tilts and weights lists

Parameters

rotCaster – method that receives the rot in degrees and returns it converted to something else, radians?

class pwem.viewers.plotter.PlotData(fileName, tableName, orderColumn, orderDirection)[source]

Bases: object

Small wrapper around table data such as: sqlite or metadata files.

pwem.viewers.plotter.eulerAngles_to_2D(rot, tilt, psi)[source]

Converts euler angles to their 2D representation for a polar plot

pwem.viewers.plotter.magnitude(x, y, z)[source]

Returns the magnitude of the vector.

pwem.viewers.plotter.to_spherical(x, y, z)[source]

Converts a cartesian coordinate (x, y, z) into a spherical one (radius, theta, phi) in radians. theta ranges from 0 t PI phi ranges from -PI to PI