Skip to content

Commit

Permalink
Creation of a stem plot from a workspace spectrum. Re #2654.
Browse files Browse the repository at this point in the history
Add a python function that allows a stem-and-leaf plot to be created
from either a table or a workspace.
  • Loading branch information
RussellTaylor committed Dec 21, 2011
1 parent b60ea54 commit 5f4e14d
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions Code/Mantid/MantidPlot/mantidplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,47 @@ def plotSpectrum(source, indices, error_bars = False, type = -1):

#-----------------------------------------------------------------------------
def plotBin(source, indices, error_bars = False, type = 0):
"""Open a 1D Plot of a spectrum in a workspace
"""Create a 1D Plot of a bin or bins in a workspace
@param source :: workspace or name of a workspace
@param indices :: workspace index or list of workspace indices to plot
@param error_bars :: bool, set to True to add error bars.
"""
return __doPlotting(source,indices,error_bars,type)


#-----------------------------------------------------------------------------
def stemPlot(source, index, power=None, startPoint=None, endPoint=None):
"""Generate a stem-and-leaf plot from an input table column or workspace spectrum
Args:
source: A reference to a workspace or a table.
index: For a table, the column number or name. For a workspace, the workspace index.
power: The stem unit as a power of 10. If not provided, a dialog will appear with a
suggested value.
startPoint: The first point (row or bin) to use (Default: the first one).
endPoint: The last point (row or bin) to use (Default: the last one).
Returns:
A string representation of the stem plot
"""
# Turn the optional arguments into the magic numbers that the C++ expects
if power==None:
power=1001
if startPoint==None:
startPoint=0
if endPoint==None:
endPoint=-1
# If the source is a workspace, create a table from the specified index
if isinstance(source,WorkspaceProxy):
wsName = source.getName()
source = qti.app.mantidUI.workspaceToTable(wsName,wsName,[index],False,True)
# The C++ stemPlot method takes the name of the column, so get that
index = source.colName(2)
# Get column name if necessary
if isinstance(index, int):
index = source.colName(index)
# Call the C++ method
return qti.app.stemPlot(source,index,power,startPoint,endPoint)

#-----------------------------------------------------------------------------
def plotSlice(source, xydim=None, slicepoint=None,
Expand Down

0 comments on commit 5f4e14d

Please sign in to comment.