plottables

danse.common.plottools.plottables

Prototype plottable object support.

The main point of this prototype is to provide a clean separation between the style (plotter details: color, grids, widgets, etc.) and substance (application details: which information to plot). Programmers should not be dictating line colours and plotting symbols.

Unlike the problem of style in CSS or Word, where most paragraphs look the same, each line on a graph has to be distinguishable from its neighbours. Our solution is to provide parametric styles, in which a number of different classes of object (e.g., reflectometry data, reflectometry theory) representing multiple graph primitives cycle through a colour palette provided by the underlying plotter.

A full treatment would provide perceptual dimensions of prominence and distinctiveness rather than a simple colour number.

class danse.common.plottools.plottables.Chisq

Bases: danse.common.plottools.plottables.Plottable

Chisq plottable plots the chisq

check_data_PlottableX()

Since no transformation is made for log10(x), check that no negative values is plot in log scale

check_data_PlottableY()

Since no transformation is made for log10(y), check that no negative values is plot in log scale

colors()

Return the number of colors need to render the object

custom_color = None
dx = None
dy = None
get_xaxis()

Return the units and name of x-axis

get_yaxis()

Return the units and name of y- axis

hidden = False
interactive = True
is_empty()

Returns True if there is no data stored in the plottable

classmethod labels()

Construct a set of unique labels for a collection of plottables of the same type.

Returns a map from plottable to name.

markersize = 5
name = None
onFitRange()

It limits View data range to plot from min to max

Parameters:
  • xmin – the minimum value of x to plot.
  • xmax – the maximum value of x to plot
onReset()

Reset x, y, dx, dy view with its parameters

render()
reset_view()

Reload view with new value to plot

returnValuesOfView()

Return View parameters and it is used by Fit Dialog

setChisq()

Set the chisq value.

setLabel()

It takes a label of the x and y transformation and set View parameters

Parameters:
  • transx – The label of x transformation is sent by Properties Dialog
  • transy – The label of y transformation is sent Properties Dialog
set_View()

Load View

set_data()
short_name = None
transformView()

It transforms x, y before displaying

transformX()

Receive pointers to function that transform x and dx and set corresponding View pointers

Parameters:
  • transx – pointer to function that transforms x
  • transdx – pointer to function that transforms dx
transformY()

Receive pointers to function that transform y and dy and set corresponding View pointers

Parameters:
  • transy – pointer to function that transforms y
  • transdy – pointer to function that transforms dy
x = None
xaxis()

Set the name and unit of x_axis

Parameters:
  • name – the name of x-axis
  • units – the units of x_axis
y = None
yaxis()

Set the name and unit of y_axis

Parameters:
  • name – the name of y-axis
  • units – the units of y_axis
class danse.common.plottools.plottables.Data1D

Bases: danse.common.plottools.plottables.Plottable

Data plottable: scatter plot of x,y with errors in x and y.

changed()
check_data_PlottableX()

Since no transformation is made for log10(x), check that no negative values is plot in log scale

check_data_PlottableY()

Since no transformation is made for log10(y), check that no negative values is plot in log scale

colors()

Return the number of colors need to render the object

custom_color = None
dx = None
dy = None
get_xaxis()

Return the units and name of x-axis

get_yaxis()

Return the units and name of y- axis

hidden = False
interactive = True
is_empty()

Returns True if there is no data stored in the plottable

classmethod labels()

Build a label mostly unique within a collection

markersize = 5
name = None
onFitRange()

It limits View data range to plot from min to max

Parameters:
  • xmin – the minimum value of x to plot.
  • xmax – the maximum value of x to plot
onReset()

Reset x, y, dx, dy view with its parameters

render()

Renders the plottable on the graph

reset_view()

Reload view with new value to plot

returnValuesOfView()

Return View parameters and it is used by Fit Dialog

setLabel()

It takes a label of the x and y transformation and set View parameters

Parameters:
  • transx – The label of x transformation is sent by Properties Dialog
  • transy – The label of y transformation is sent Properties Dialog
set_View()

Load View

set_data()
short_name = None
transformView()

It transforms x, y before displaying

transformX()

Receive pointers to function that transform x and dx and set corresponding View pointers

Parameters:
  • transx – pointer to function that transforms x
  • transdx – pointer to function that transforms dx
transformY()

Receive pointers to function that transform y and dy and set corresponding View pointers

Parameters:
  • transy – pointer to function that transforms y
  • transdy – pointer to function that transforms dy
x = None
xaxis()

Set the name and unit of x_axis

Parameters:
  • name – the name of x-axis
  • units – the units of x_axis
y = None
yaxis()

Set the name and unit of y_axis

Parameters:
  • name – the name of y-axis
  • units – the units of y_axis
class danse.common.plottools.plottables.Data2D

Bases: danse.common.plottools.plottables.Plottable

2D data class for image plotting

changed()
check_data_PlottableX()

Since no transformation is made for log10(x), check that no negative values is plot in log scale

check_data_PlottableY()

Since no transformation is made for log10(y), check that no negative values is plot in log scale

colors()

Return the number of colors need to render the object

custom_color = None
dx = None
dy = None
get_xaxis()

Return the units and name of x-axis

get_yaxis()

Return the units and name of y- axis

hidden = False
interactive = True
is_empty()

Returns True if there is no data stored in the plottable

classmethod labels()

Build a label mostly unique within a collection

markersize = 5
name = None
onFitRange()

It limits View data range to plot from min to max

Parameters:
  • xmin – the minimum value of x to plot.
  • xmax – the maximum value of x to plot
onReset()

Reset x, y, dx, dy view with its parameters

render()

Renders the plottable on the graph

reset_view()

Reload view with new value to plot

returnValuesOfView()

Return View parameters and it is used by Fit Dialog

setLabel()

It takes a label of the x and y transformation and set View parameters

Parameters:
  • transx – The label of x transformation is sent by Properties Dialog
  • transy – The label of y transformation is sent Properties Dialog
setValues()

Use datainfo object to initialize data2D

Parameters:datainfo – object
set_View()

Load View

set_data()
set_zrange()
short_name = None
transformView()

It transforms x, y before displaying

transformX()

Receive pointers to function that transform x and dx and set corresponding View pointers

Parameters:
  • transx – pointer to function that transforms x
  • transdx – pointer to function that transforms dx
transformY()

Receive pointers to function that transform y and dy and set corresponding View pointers

Parameters:
  • transy – pointer to function that transforms y
  • transdy – pointer to function that transforms dy
x = None
xaxis()

set x-axis

Parameters:
  • label – x-axis label
  • unit – x-axis unit
y = None
yaxis()

set y-axis

Parameters:
  • label – y-axis label
  • unit – y-axis unit
zaxis()

set z-axis

Parameters:
  • label – z-axis label
  • unit – z-axis unit
class danse.common.plottools.plottables.Fit1D

Bases: danse.common.plottools.plottables.Plottable

Fit plottable: composed of a data line plus a theory line. This is treated like a single object from the perspective of the graph, except that it will have two legend entries, one for the data and one for the theory.

The color of the data and theory will be shared.

changed()
check_data_PlottableX()

Since no transformation is made for log10(x), check that no negative values is plot in log scale

check_data_PlottableY()

Since no transformation is made for log10(y), check that no negative values is plot in log scale

colors()

Return the number of colors need to render the object

custom_color = None
dx = None
dy = None
get_xaxis()

Return the units and name of x-axis

get_yaxis()

Return the units and name of y- axis

hidden = False
interactive = True
is_empty()

Returns True if there is no data stored in the plottable

classmethod labels()

Construct a set of unique labels for a collection of plottables of the same type.

Returns a map from plottable to name.

markersize = 5
name = None
onFitRange()

It limits View data range to plot from min to max

Parameters:
  • xmin – the minimum value of x to plot.
  • xmax – the maximum value of x to plot
onReset()

Reset x, y, dx, dy view with its parameters

render()
reset_view()

Reload view with new value to plot

returnValuesOfView()

Return View parameters and it is used by Fit Dialog

setLabel()

It takes a label of the x and y transformation and set View parameters

Parameters:
  • transx – The label of x transformation is sent by Properties Dialog
  • transy – The label of y transformation is sent Properties Dialog
set_View()

Load View

set_data()
short_name = None
transformView()

It transforms x, y before displaying

transformX()

Receive pointers to function that transform x and dx and set corresponding View pointers

Parameters:
  • transx – pointer to function that transforms x
  • transdx – pointer to function that transforms dx
transformY()

Receive pointers to function that transform y and dy and set corresponding View pointers

Parameters:
  • transy – pointer to function that transforms y
  • transdy – pointer to function that transforms dy
x = None
xaxis()

Set the name and unit of x_axis

Parameters:
  • name – the name of x-axis
  • units – the units of x_axis
y = None
yaxis()

Set the name and unit of y_axis

Parameters:
  • name – the name of y-axis
  • units – the units of y_axis
class danse.common.plottools.plottables.Graph

Generic plottables graph structure.

Plot styles are based on color/symbol lists. The user gets to select the list of colors/symbols/sizes to choose from, not the application developer. The programmer only gets to add/remove lines from the plot and move to the next symbol/color.

Another dimension is prominence, which refers to line sizes/point sizes.

Axis transformations allow the user to select the coordinate view which provides clarity to the data. There is no way we can provide every possible transformation for every application generically, so the plottable objects themselves will need to provide the transformations. Here are some examples from reflectometry:

independent: x -> f(x)
   monitor scaling: y -> M*y
   log:  y -> log(y if y > min else min)
   cos:  y -> cos(y*pi/180)
dependent:   x -> f(x,y)
   Q4:      y -> y*x^4
   fresnel: y -> y*fresnel(x)
coordinated: x,y = f(x,y)
   Q:    x -> 2*pi/L (cos(x*pi/180) - cos(y*pi/180))
         y -> 2*pi/L (sin(x*pi/180) + sin(y*pi/180))
reducing: x,y = f(x1,x2,y1,y2)
   spin asymmetry: x -> x1, y -> (y1 - y2)/(y1 + y2)
   vector net: x -> x1, y -> y1*cos(y2*pi/180)

Multiple transformations are possible, such as Q4 spin asymmetry

Axes have further complications in that the units of what are being plotted should correspond to the units on the axes. Plotting multiple types on the same graph should be handled gracefully, e.g., by creating a separate tab for each available axis type, breaking into subplots, showing multiple axes on the same plot, or generating inset plots. Ultimately the decision should be left to the user.

Graph properties such as grids/crosshairs should be under user control, as should the sizes of items such as axis fonts, etc. No direct access will be provided to the application.

Axis limits are mostly under user control. If the user has zoomed or panned then those limits are preserved even if new data is plotted. The exception is when, e.g., scanning through a set of related lines in which the user may want to fix the limits so that user can compare the values directly. Another exception is when creating multiple graphs sharing the same limits, though this case may be important enough that it is handled by the graph widget itself. Axis limits will of course have to understand the effects of axis transformations.

High level plottable objects may be composed of low level primitives. Operations such as legend/hide/show copy/paste, etc. need to operate on these primitives as a group. E.g., allowing the user to have a working canvas where they can drag lines they want to save and annotate them.

Graphs need to be printable. A page layout program for entire plots would be nice.

add()

Add a new plottable to the graph

changed()

Detect if any graphed plottables have changed

delete()

Remove an existing plottable from the graph

get()

Get the graph properties

get_plottable()

Return the plottable with the given name if it exists. Otherwise return None

get_range()

Return the range of all displayed plottables

isPlotted()

Return True is the plottable is already on the graph

render()

Redraw the graph

replace()

Replace an existing plottable from the graph

reset()

Reset the graph.

reset_scale()

Resets the scale transformation data to the underlying data

returnPlottable()

This method returns a dictionary of plottables contained in graph It is just by Plotpanel to interact with the complete list of plottables inside the graph.

set()

Set the graph properties

title()

Graph title

xaxis()

Properties of the x axis.

yaxis()

Properties of the y axis.

class danse.common.plottools.plottables.Plottable

Bases: object

check_data_PlottableX()

Since no transformation is made for log10(x), check that no negative values is plot in log scale

check_data_PlottableY()

Since no transformation is made for log10(y), check that no negative values is plot in log scale

colors()

Return the number of colors need to render the object

custom_color = None
dx = None
dy = None
get_xaxis()

Return the units and name of x-axis

get_yaxis()

Return the units and name of y- axis

hidden = False
interactive = True
is_empty()

Returns True if there is no data stored in the plottable

classmethod labels()

Construct a set of unique labels for a collection of plottables of the same type.

Returns a map from plottable to name.

markersize = 5
name = None
onFitRange()

It limits View data range to plot from min to max

Parameters:
  • xmin – the minimum value of x to plot.
  • xmax – the maximum value of x to plot
onReset()

Reset x, y, dx, dy view with its parameters

render()

The base class makes sure the correct units are being used for subsequent plottable.

For now it is assumed that the graphs are commensurate, and if you put a Qx object on a Temperature graph then you had better hope that it makes sense.

reset_view()

Reload view with new value to plot

returnValuesOfView()

Return View parameters and it is used by Fit Dialog

setLabel()

It takes a label of the x and y transformation and set View parameters

Parameters:
  • transx – The label of x transformation is sent by Properties Dialog
  • transy – The label of y transformation is sent Properties Dialog
set_View()

Load View

set_data()
short_name = None
transformView()

It transforms x, y before displaying

transformX()

Receive pointers to function that transform x and dx and set corresponding View pointers

Parameters:
  • transx – pointer to function that transforms x
  • transdx – pointer to function that transforms dx
transformY()

Receive pointers to function that transform y and dy and set corresponding View pointers

Parameters:
  • transy – pointer to function that transforms y
  • transdy – pointer to function that transforms dy
x = None
xaxis()

Set the name and unit of x_axis

Parameters:
  • name – the name of x-axis
  • units – the units of x_axis
y = None
yaxis()

Set the name and unit of y_axis

Parameters:
  • name – the name of y-axis
  • units – the units of y_axis
class danse.common.plottools.plottables.Text

Bases: danse.common.plottools.plottables.Plottable

check_data_PlottableX()

Since no transformation is made for log10(x), check that no negative values is plot in log scale

check_data_PlottableY()

Since no transformation is made for log10(y), check that no negative values is plot in log scale

colors()

Return the number of colors need to render the object

custom_color = None
dx = None
dy = None
getText()

Get the text string.

get_xaxis()

Return the units and name of x-axis

get_yaxis()

Return the units and name of y- axis

hidden = False
interactive = True
is_empty()

Returns True if there is no data stored in the plottable

classmethod labels()

Construct a set of unique labels for a collection of plottables of the same type.

Returns a map from plottable to name.

markersize = 5
name = None
onFitRange()

It limits View data range to plot from min to max

Parameters:
  • xmin – the minimum value of x to plot.
  • xmax – the maximum value of x to plot
onReset()

Reset x, y, dx, dy view with its parameters

render()
reset_view()

Reload view with new value to plot

returnValuesOfView()

Return View parameters and it is used by Fit Dialog

setLabel()

It takes a label of the x and y transformation and set View parameters

Parameters:
  • transx – The label of x transformation is sent by Properties Dialog
  • transy – The label of y transformation is sent Properties Dialog
setText()

Set the text string.

set_View()

Load View

set_data()
set_x()

Set the x position of the text ACCEPTS: float

set_y()

Set the y position of the text ACCEPTS: float

short_name = None
transformView()

It transforms x, y before displaying

transformX()

Receive pointers to function that transform x and dx and set corresponding View pointers

Parameters:
  • transx – pointer to function that transforms x
  • transdx – pointer to function that transforms dx
transformY()

Receive pointers to function that transform y and dy and set corresponding View pointers

Parameters:
  • transy – pointer to function that transforms y
  • transdy – pointer to function that transforms dy
x = None
xaxis()

Set the name and unit of x_axis

Parameters:
  • name – the name of x-axis
  • units – the units of x_axis
y = None
yaxis()

Set the name and unit of y_axis

Parameters:
  • name – the name of y-axis
  • units – the units of y_axis
class danse.common.plottools.plottables.Theory1D

Bases: danse.common.plottools.plottables.Plottable

Theory plottable: line plot of x,y with confidence interval y.

changed()
check_data_PlottableX()

Since no transformation is made for log10(x), check that no negative values is plot in log scale

check_data_PlottableY()

Since no transformation is made for log10(y), check that no negative values is plot in log scale

colors()

Return the number of colors need to render the object

custom_color = None
dx = None
dy = None
get_xaxis()

Return the units and name of x-axis

get_yaxis()

Return the units and name of y- axis

hidden = False
interactive = True
is_empty()

Returns True if there is no data stored in the plottable

classmethod labels()

Build a label mostly unique within a collection

markersize = 5
name = None
onFitRange()

It limits View data range to plot from min to max

Parameters:
  • xmin – the minimum value of x to plot.
  • xmax – the maximum value of x to plot
onReset()

Reset x, y, dx, dy view with its parameters

render()
reset_view()

Reload view with new value to plot

returnValuesOfView()

Return View parameters and it is used by Fit Dialog

setLabel()

It takes a label of the x and y transformation and set View parameters

Parameters:
  • transx – The label of x transformation is sent by Properties Dialog
  • transy – The label of y transformation is sent Properties Dialog
set_View()

Load View

set_data()
short_name = None
transformView()

It transforms x, y before displaying

transformX()

Receive pointers to function that transform x and dx and set corresponding View pointers

Parameters:
  • transx – pointer to function that transforms x
  • transdx – pointer to function that transforms dx
transformY()

Receive pointers to function that transform y and dy and set corresponding View pointers

Parameters:
  • transy – pointer to function that transforms y
  • transdy – pointer to function that transforms dy
x = None
xaxis()

Set the name and unit of x_axis

Parameters:
  • name – the name of x-axis
  • units – the units of x_axis
y = None
yaxis()

Set the name and unit of y_axis

Parameters:
  • name – the name of y-axis
  • units – the units of y_axis
class danse.common.plottools.plottables.Transform

Define a transform plugin to the plottable architecture.

Transforms operate on axes. The plottable defines the set of transforms available for it, and the axes on which they operate. These transforms can operate on the x axis only, the y axis only or on the x and y axes together.

This infrastructure is not able to support transformations such as log and polar plots as these require full control over the drawing of axes and grids.

A transform has a number of attributes.

name: user visible name for the transform. This will
appear in the context menu for the axis and the transform menu for the graph.
type: operational axis. This determines whether the
transform should appear on x,y or z axis context menus, or if it should appear in the context menu for the graph.
inventory: (not implemented)

a dictionary of user settable parameter names and their associated types. These should appear as keyword arguments to the transform call. For example, Fresnel reflectivity requires the substrate density:

{ ‘rho’: type.Value(10e-6/units.angstrom**2) }

Supply reasonable defaults in the callback so that limited plotting clients work even though they cannot set the inventory.

class danse.common.plottools.plottables.View

Representation of the data that might include a transformation

check_data_logX()

Remove negative value in x vector to avoid plotting negative value of Log10

check_data_logY()

Remove negative value in y vector to avoid plotting negative value of Log10

dx = None
dy = None
onFitRangeView()

It limits View data range to plot from min to max

Parameters:
  • xmin – the minimum value of x to plot.
  • xmax – the maximum value of x to plot
onResetView()

Reset x,y,dx and y in their full range and in the initial scale in case their previous range has changed

returnXview()

Return View x,y,dx,dy

setTransformX()

Receive pointers to function that transform x and dx and set corresponding View pointers

Parameters:
  • transx – pointer to function that transforms x
  • transdx – pointer to function that transforms dx
setTransformY()

Receive pointers to function that transform y and dy and set corresponding View pointers

Parameters:
  • transx – pointer to function that transforms y
  • transdx – pointer to function that transforms dy
transform()
Transforms the x,y,dx and dy vectors and stores
the output in View parameters
Parameters:
  • x – array of x values
  • y – array of y values
  • dx – array of errors values on x
  • dy – array of error values on y
x = None
y = None
danse.common.plottools.plottables.all()
danse.common.plottools.plottables.any()
danse.common.plottools.plottables.demo_plotter()
danse.common.plottools.plottables.sample_graph()

Table Of Contents

Previous topic

plottable_interactor

Next topic

PropertyDialog

This Page