fudge.vis.matplotlib package

Submodules

fudge.vis.matplotlib.plot2d module

class fudge.vis.matplotlib.plot2d.AxisSettings(axisMin=None, axisMax=None, autoscale=True, isLog=False, unit=None, gridOn=False, label=None, font=None, fontSize=20, fontWeight='normal')[source]

Bases: fudge.vis.matplotlib.plot2d.TextSettings

Member data (set these with __init__ function)

- `axisMin` :  min value of the axis 
    This is optional and defaults to `None` causing autoscaling.  
    If given as float, we assume in units of `unit`.  
    If given as a PQU instance, we'll 
    attempt to convert it to `unit`.
- `axisMax` : max value of the axis.  See axisMin for usage
- `isLog` : (optional, defaults to False) False == linear, True == semilog
- `unit` : (optional, defaults to None), must be None or something that is usable in a 
     PQU instance
- `gridOn` : (optional)
setupAxis(theAxis)[source]
class fudge.vis.matplotlib.plot2d.DataSet2d(data, uncertainty=None, xUnit=None, yUnit=None, dataType=None, infill=False, **kw)[source]

Bases: fudge.vis.matplotlib.plot2d.DataSetParameters

Member data (set these with __init__ function):

  • data: the data as either a list of [ x, y ] pairs or as an object that has the method copyDataToXsAndYs (and also toPointwise_withLinearXYs if infill is True).
  • uncertainty: the uncertainty on the data as either a list of [ x, y ] pairs or as an object that has the method evaluate.
  • dataType (‘scatter’, ‘line’, or None): by default lists of points are rendered as ‘scatter’ and the others as ‘line’. Override the default behavior with this keyword.
  • xUnits: If the data object has an axes member, units are taken from it. Otherwise this argument is used to for the x units. When the units are given as None and the data/uncertainty do not have an axes member units are assumed to match those of the plot axis. The default is None.
  • yUnits: Units for the y-axis. See xUnits for more information.

type help(DataSetParameters) to find out about how to set the line properties, etc. All of this information is passed on though the __init__ function of DataSet2d to DataSetParameters.

addToPlot(thePlot, logY=False, minY=1e-12, verbose=False)[source]
convertUnits(xUnit=None, yUnit=None)[source]

Convert self’s units to xUnit and yUnit

dimension
class fudge.vis.matplotlib.plot2d.DataSet3d(data, dataType=None, xUnit=None, yUnit=None, zUnit=None, **kw)[source]

Bases: fudge.vis.matplotlib.plot2d.DataSetParameters

Member data (set these with __init__ function):

  • data
  • dataType (None)

type help(DataSetParameters) to find out about how to set the line properties, etc. All of this information is passed on though the __init__ function of DataSet2d to DataSetParameters.

addToPlot(thePlot, plotType='contour', numContours=10, logX=False, logY=False)[source]

Default plotType set to ‘contour’ so that can use the __makePlot2d function to drive both the regular 2d plotting and contour plotting

convertUnits(xUnit=None, yUnit=None, zUnit=None)[source]

Convert self’s units to xUnit and yUnit and zUnit

dimension
getW_XYs()[source]
class fudge.vis.matplotlib.plot2d.DataSetParameters(legend='', symbol=None, symbolSize=5, color=None, lineStyle=None, lineWidth=None, errorbarCapSize=3, errorbarLineWidth=1.5, errorbarColor=None, formatString=None, dataType=None)[source]

Bases: object

Base class for all DataSet classes (DataSet2d, DataSet3d, …)

Member data (set these with __init__ function):

  • legend (optional, defaults to ‘’)
  • symbol
  • symbolColor
  • symbolSize
  • lineStyle
  • lineColor
  • lineWidth

Commands which take color arguments can use several formats to specify the colors. For the basic builtin colors, you can use a single letter

character description
b blue
g green
r red
c cyan
m magenta
y yellow
k black
w white

Gray shades can be given as a string encoding a float in the 0-1 range, e.g.:

>>> color = '0.75'

For a greater range of colors, you have two options. You can specify the color using an html hex string, as in:

>>> color = '#eeefff'

or you can pass an R , G , B tuple, where each of R , G , B are in the range [0,1]. Finally, legal html names for colors, like “red”, “burlywood” and “chartreuse” are supported.

The following format string characters are accepted to control the line style or marker:

character description
‘-‘ solid line style
‘–’ dashed line style
‘-.’ dash-dot line style
‘:’ dotted line style
‘.’ point marker
‘,’ pixel marker
‘o’ circle marker
‘v’ triangle_down marker
‘^’ triangle_up marker
‘<’ triangle_left marker
‘>’ triangle_right marker
‘1’ tri_down marker
‘2’ tri_up marker
‘3’ tri_left marker
‘4’ tri_right marker
‘s’ square marker
‘p’ pentagon marker
‘*’ star marker
‘h’ hexagon1 marker
‘H’ hexagon2 marker
‘+’ plus marker
‘x’ x marker
‘D’ diamond marker
‘d’ thin_diamond marker
‘|’ vline marker
‘_’ hline marker
addToPlot(thePlot)[source]
getFormatMap(doErrors=False)[source]
getFormatString()[source]

Attempt to make simple format string for maptplotlib use.

fudge.vis.matplotlib.plot2d.INCLASSAXISSETTING = False

A few words about MatPlotLib symbols (“markers” in MatPlotLib-speak)…

. point , pixel o circle v triangle_down ^ triangle_up < triangle_left > triangle_right 1 tri_down – DAB 11/17/2014: doesn’t show up 2 tri_up – DAB 11/17/2014: doesn’t show up 3 tri_left – DAB 11/17/2014: doesn’t show up 4 tri_right – DAB 11/17/2014: doesn’t show up 8 octagon s square p pentagon * star h hexagon1 H hexagon2 + plus – DAB 11/17/2014: barely visable x x – DAB 11/17/2014: barely visable D diamond d thin_diamond | vline – DAB 11/17/2014: doesn’t show up _ hline – DAB 11/17/2014: doesn’t show up

class fudge.vis.matplotlib.plot2d.TextSettings(text=None, font=None, fontSize=12, fontWeight='bold')[source]

Bases: object

Base class for text objects in plots

Member data (set these with __init__ function):

  • text the text itself
  • font the font (e.g. Helvetica) (optional)
  • fontSize font size in points (optional, defaults to 14)
  • fontWeight font weight (e.g. bold) (optional)
fudge.vis.matplotlib.plot2d.convertUnit(unitFrom, unitTo, xs, xErrs, legend)[source]
fudge.vis.matplotlib.plot2d.makePlot2d(datasets, xAxisSettings=None, yAxisSettings=None, title='', legendOn=False, outFile=None, legendXY=(0.05, 0.95), figsize=(20, 10), infill=False, useBokeh=False)[source]

Plain, vanilla, 2d plots.

Arguments

* datasets (required), list of DataSet objects to plot
* xAxisSettings (optional) 
* yAxisSettings (optional)
* title (optional, defaults to '' )
* legendOn (optional, defaults to True)
* outFile, if not None, use this to output plot instead of generating a matplotlib window
* legendXY, upper left corner of legend (optional, defaults to ( 0.05, 0.95 ))
* figsize (optional, defaults to ( 20, 10 ))
* infill
fudge.vis.matplotlib.plot2d.makePlot2dContour(datasets, xAxisSettings=None, yAxisSettings=None, numContours=10, title='', figsize=(20, 10), legendOn=False, outFile=None, useBokeh=False)[source]

Contour plots:

  • datasets (required): list of DataSet objects to plot, one works better than many for a contour plot
  • xAxisSettings (optional)
  • yAxisSettings (optional)
  • numContours (optional, defaults to 10): number of contours in the plot assuming linear spacing between intervals from the min to max data values
  • title (optional, defaults to ‘’ )
  • legendOn (optional, defaults to True)
  • outFile (optional)
fudge.vis.matplotlib.plot2d.makePlot2dSlice(datasets, xyAxisSettings=None, zAxisSettings=None, sliceXCoords=None, sliceYCoords=None, sliceUnits='', title='', legendOn=True, legendXY=(0.05, 0.95), figsize=(20, 10), outFile=None, useBokeh=False)[source]

Make a slice of a dataset of 3d data objects along a fixed x line or a fixed y line.

Any 2d objects get plotted as if they are xy data in the correct plane for plotting.

In other words, at fixed sliceXCoord = 2, all 3d functions F( x, y ) get plotted as y vs. F( 2.0, y ) and all 2d functions G( x ) are plotted as x vs. G( x ) even if you meant something different.

  • datasets (required): list of DataSet objects to plot
  • xyAxisSettings (optional)
  • zAxisSettings (optional)
  • sliceXCoords: a list or value
  • sliceYCoords: a list or value
  • title (optional, defaults to ‘’ )
  • legendOn (optional, defaults to True)
  • outFile (optional)
fudge.vis.matplotlib.plot2d.nLineStyles = 4

A few words about MatPlotLib colors….

Commands which take color arguments can use several formats to specify the colors. For the basic built-in colors, you can use a single letter

b: blue g: green r: red c: cyan m: magenta y: yellow k: black w: white Gray shades can be given as a string encoding a float in the 0-1 range, e.g.:

color = ‘0.75’ For a greater range of colors, you have two options. You can specify the color using an html hex string, as in:

color = ‘#eeefff’ or you can pass an R , G , B tuple, where each of R , G , B are in the range [0,1].

Finally, legal html names for colors, like ‘red’, ‘burlywood’ and ‘chartreuse’ are supported.

fudge.vis.matplotlib.plot2d.plotTests(tests=[False, False, False, False, False, False, False, False, False, False, False])[source]

fudge.vis.matplotlib.plot_matrix module

fudge.vis.matplotlib.plot_matrix.generateColorMap()[source]
fudge.vis.matplotlib.plot_matrix.plot_matrix(matrix, energyBoundariesX=None, energyBoundariesY=None, title='Matrix', xyTitle='Energy (MeV)', xylog=False, zlog=False, zRange=(), switchY=True, colorMap='jet', subplot=None)[source]

Plot a matrix. Arguments are: @matrix (required): 2-dimensional numpy array (or equivalent) @energyBoundariesX: list of group boundary edges. If omitted, use matrix indices for axis @energyBoundariesY: “”. If omitted, use same boundaries as x-axis @title @xyTitle: specify x (and optionally y) titles. May be string or tuple of two strings @xylog: if True, energyBoundariesX (and Y if different) must also be specified @zlog @zRange: for plotting a sub-range of z @switchY: if True, plot matrix[0,0] at upper left rather than lower left @colorMap: select color range for z-axis. Options include ‘jet’, ‘jet_r’, ‘correlation’, etc. @subplot: matplotlib.axes.AxesSubplot instance (for drawing matrix inside larger figure)

This prepares a 2-d matrix plot. Use pyplot.show() to view the result.

Module contents