Bases: decida.ItclObjectx.ItclObjectx, Tkinter.Frame
2-dimensional plot base-class.
synopsis:
PlotBase is a base-class for plotting classes. It provides a central canvas for displaying the plot, controls for changing aspects of the plot, point display boxes, and mouse commands for zooming, annotating, and determining line-parameters.
PlotBase provides its own vector (Hershey) fonts, which can be rotated, slanted, and sized. The Tkinter canvas does provide a font set, but with some limitations.
PlotBase is inherited by XYplotx, Histogramx, Contourx, and Smithchartx.
configuration options:
- verbose (bool, default=False)
enable/disable verbose mode
- title (string, default="")
main title
- xtitle (string, default="")
x-axis title
- ytitle (string, default="")
y-axis title
- plot_height (string, default="10i" for MacOS, else "6i")
Height of plot window (Tk inch or pixel specification)
- plot_width (string, default="10i" for MacOS, else "6i")
Width of plot window (Tk inch or pixel specification)
- plot_background (string, default="GhostWhite")
Background color of plot window
- legend_background (string, default="AntiqueWhite2")
Background color of legend
- colors (list of strings, default =
- "blue", "red", "green", "orange", "cyan",
- "brown", "black", "blue violet", "cadet blue",
- "dark cyan", "dark goldenrod", "dark green",
- "dark magenta", "dark olive green", "dark orange",
- "dark red", "dark slate blue", "dark slate gray",
- "dodger blue", "forest green", "steel blue", "sienna"
- )
list of colors for curves. Used to populate color menu, and to specify curve colors in scripted “command” option in derived classes.
- symbols (list of strings, default =
- "none", "dot", "square", "diamond",
- "triangle", "itriangle",
- "dash", "pipe", "plus", "cross",
- "spade", "heart", "diam", "club", "shamrock",
- "fleurdelis", "circle", "star"
- )
list of symbols for curves. Used to populate symbol menu, and to specify curve symbols in scripted “command” option in derived classes.
- ssizes (list of floats, default = [0.01])
list of symbol sizes for curves. Used to specify curve symbol sizes in scripted “command” option in derived classes.
- wlines (list of ints, default = [1])
list of line widths for curves. Used to specify curve line widths in scripted “command” option in derived classes.
- traces (list, default = ["increasing"])
list of traces for curves. each trace can be one of: “increasing”, “decreasing”, or “both”. Used to specify curve trace directions in scripted “command” option in derived classes.
- xaxis (string, default="lin")
linear or logarithmic axis: “lin” or “log”
- yaxis (string, default="lin")
linear or logarithmic axis: “lin” or “log”
- xmin (float, default=0.0)
xaxis minimum
- xmax (float, default=0.0)
xaxis maximum
- ymin (float, default=0.0)
yaxis minimum
- ymax (float, default=0.0)
yaxis maximum
- grid (bool, default=True)
if true, show grid on plot
- legend (bool, default=True)
if true, show legend on plot
- postscript (bool, default=False)
if true, generate a PostScript file.
- postscript_file (string, default="plot.ps")
name of PostScript file to plot to
- wait (bool, default=False)
wait in main-loop until window is destroyed.
- destroy (bool, default=False)
destroy main window after it has been displayed. useful for displaying, generating PostScript, then destroying window.
protected methods:
- _plot_curves
- _settings_cmd
public methods:
- public methods from ItclObjectx
add a curve.
arguments:
- datobj (Data pointer)
data object supplying points to add to curve.
- xcol (string)
x column name.
- ycol (string)
x column name.
- start (bool) (optional, default=False)
modify x, y titles if this is the first and only curve.
- autoscale_x (bool) (optional, default=False)
widen x-axis to fit all curves. if strict, narrow x-axis to minimum and maximum of all curves.
- autoscale_y (bool) (optional, default=True)
widen y-axis to fit all curves. if strict, narrow y-axis to minimum and maximum of all curves.
- strict (bool) (optional, default=False)
if false, rescale and redraw only if current plot limits are smaller than minimum and maximum of all curves
- dname (string) (optional, default=None)
specify data name. if not specified, dname = data_1.
- lstate (bool) (optional, default=True)
specify line-state.
- sstate (bool) (optional, default=true)
specify symbol-state.
- color (string) (optional, default=None)
specify curve color. if not specified, chooses next color in color list.
- symbol (string) (optional, default=None)
specify curve symbol. if not specified, chooses next symbol in symbol list. if symbol list wasn’t configured, then symbol=none.
- ssize (float) (optional, default=None)
specify curve symbol size. if not specified, chooses next symbol size in symbol size list.
- wline (float) (optional, default=None)
specify curve line width. if not specified, chooses next line width in line width list.
- trace (string) (optional, default=None)
specify curve trace. if not specified, chooses next trace in trace list
results:
- Registers a new curve with a curve id in the format:
<data_name>_:_<ycol>_vs_<xcol> If data_name is undefined, it is set to “data_1”
Plot is re-drawn with the new curve.
New curve is selected as the current curve.
find limits and autoscale plot.
arguments:
- autoscale_x (bool) (optional, default=False)
widen x-axis to fit all curves. if strict, narrow x-axis to minimum and maximum of all curves
- autoscale_y (bool) (optional, default=True)
widen y-axis to fit all curves. if strict, narrow y-axis to minimum and maximum of all curves
- strict (bool) (optional, default=False)
if false, rescale and redraw only if current plot limits are smaller than minimum and maximum of all curves
- redraw (bool) (optional, default=False)
if true, do redraw for any case of limit comparisons
results:
- The plot is re-drawn with the new limits.
mouse down call-back.
arguments:
- mode (str)
mode string: one of
- “zoom” : zoom in to window
- “delete” : delete labels within window
- “report” : report line-parameters
- “label” : annotate plot
- func (function)
function to call on end_stretch
- u, v (int)
canvas coordinates
results:
- Registers the stretch function, mode, and beginning coordinates.
- Updates the coordinate display.
mouse movement after mouse down call-back.
arguments:
- u, v (int)
canvas coordinates
results:
- Redraws rectangle or line, depending on the stretch operation.
- Updates the coordinate display.
return the current curve.
results:
- Returns the current curve id.
return curve attributes.
arguments:
- curve (str)
The curve id is in the format (see add_curve): <data_name>_:_<ycol>_vs_<xcol> If data_name is undefined, it is set to “data_1”
results:
Returns a list of curve attributes in the Dictionary V:
- V[“dname”] = data name (str)
- V[“xname”] = x-column name (str)
- V[“yname”] = y-column name (str)
- V[“color”] = curve color (str)
- V[“symbol”] = curve symbol (str)
- V[“ssize”] = curve symbol size (int)
- V[“wline”] = curve line-width (int)
- V[“trace”] = trace direction (str) (“increasing”, “decreasing”, or “both”)
- V[“lstate”] = line display state (bool)
- V[“sstate”] = symbol display state (bool)
return list of curves.
results:
- Returns the list of curve id’s in the plot.
delete a curve.
arguments:
- curve (string)
label of curve to delete. curve labels appear in the curve menu. the label is in the format <data_name>_:_<ycol>_vs_<xcol> where data_name is the name of the data object and xcol and ycol are the x and y column names in the curve.
- redraw (bool) (optional, default=True)
if True, redraw plot after deleting curve
results:
- The specified curve is de-registered.
- If redraw is True, redraw the Plot.
mouse up call-back.
arguments:
- u, v (int)
canvas coordinates
results:
- Calls the registered stretch function with the two canvas endpoints defined by begin_stretch and end_stretch.
- Updates the coordinate display.
return plot limits.
results:
- returns a list of the current plotting limits: [xmin, xmax, ymin, ymax]
add a line (or an arrowed line) to a curve with a label.
arguments:
- shape (str)
shape to draw on the plot. One of:
- NONE : no shape.
- LINE : line segment between two enpoints.
- RECTANGLE : rectangle using two endpoints.
- FILLED-RECTANGLE : filled rectangle using two endpoints.
- ARROW-TO : arrow from 1st point with arrow on 2nd.
- ARROW-FROM : arrow from 2nd point with arrow on 1st.
- text (str)
text to draw on the plot.
- x1, y1, x2, y2
x and y coordinates cooresponding to the window where the plot is to be annotated.
- tag (str)
Tkinter canvas tag to assign to the annotation.
results:
- Display a dialog for the user to select text or shapes to annotate the plot.
add a line (or an arrowed line) to a curve with a label.
arguments:
- x1, y1, x2, y2
x and y coordinates cooresponding to the window where the plot is to be annotated.
results:
- Display a dialog for the user to select text or shapes to annotate the plot.
convert scaled coordinates (0, 1, 0, 1) to canvas coordinates.
arguments:
- s, t (float)
x, y coordinates in scaled domain. In the scaled domain, every point on the canvas is mapped to the window smin, smax = 0.0, 1.0 and tmin, tmax = 0.0, 1.0
results:
- return canvas coordinates u, v
convert scaled coordinates (0, 1, 0, 1) to x, y coordinates
arguments:
- s, t (float)
x, y coordinates in scaled domain. In the scaled domain, every point on the canvas is mapped to the window smin, smax = 0.0, 1.0 and tmin, tmax = 0.0, 1.0
results:
- return x, y coordinates x, y
plot a symbol.
arguments:
- sp, tp
plot location in scaled coordinates. In the scaled domain, every point on the canvas is mapped to the window smin, smax = 0.0, 1.0 and tmin, tmax = 0.0, 1.0
- hp
size of the symbol to be drawn in scaled units.
- symbol (str)
the name of the symbol to be drawn. One of:
- spade : (Hershey) spade
- heart : (Hershey) heart
- diam : (Hershey) diamond
- club : (Hershey) club
- shamrock : (Hershey) shamrock
- fleurdelis : (Hershey) Fleur-de-lis
- circle : (Hershey) circle
- star : (Hershey) star
- dot : dot
- square : square
- diamond : diamond
- triangle : triangle
- itriangle : inverted triangle
- dash : dash
- pipe : pipe
- plus : plus
- cross : cross
- tags (str)
Tkinter canvas tags to apply to the symbol.
plot a text string.
arguments:
- sp, tp (float)
plot location in scaled coordinates. In the scaled domain, every point on the canvas is mapped to the window smin, smax = 0.0, 1.0 and tmin, tmax = 0.0, 1.0
- hp (float)
size of the text to be drawn in scaled units.
- stringp (str)
the string to label.
If control_mode is True, the following control sequences are respected:
single-character control sequences:
- & greek characters follow
- $ script characters follow
- ^ super-script
- ~ subscript
- @ increase character size
- # decrease character size
- % toggle overstrike mode
- back-space
- ! begin two-letter control sequence
two-letter control sequences:
- !0 font family 0
- !1 font family 1
- !2 font family 2
- !3 font family 3
- != toggle constant spacing mode
- !- toggle connected mode
- !| stretch by 1.2
- !~ shrink by 1.2
- !. ignore any following control sequences
- **kwargs (Dictionary)
options.
options:
- tags (str, default="STRING")
Tkinter canvas tags to apply to the symbol.
- rotate (float, default=0.0)
The rotation angle in degrees of the string label.
- slant (float, default=0.0)
The slant angle in degrees of the string label.
- anchor (str, default="c")
The alignment of text with respect to sp, tp. One of:
“c” : x:centered y: centered
“n” : x:centered y: north of sp, tp
“s” : x:centered y: south of sp, tp
“e” : x:east of sp, tp y: centered
“w” : x:west of sp, tp y: centered
“ne” : x:east of sp, tp y: north of sp, tp
“nw” : x:west of sp, tp y: north of sp, tp
“se” : x:east of sp, tp y: south of sp, tp
“sw” : x:west of sp, tp y: south of sp, tp
- control_mode (bool, default=True)
if True, respect control sequences, listed in stringp option description
- -1)¶
specify one character in the Hershey font set to be printed, an integer between 0 and 1535.
return the transform dictionary entry.
arguments:
- entry (str)
the transform entry to return. One of:
- uv_max_limits: maximum canvas limits
- st_max_limits: maximum scaled limits
- xy_max_limits: maximum x,y limits
- uv_limits: current canvas limits
- st_limits: current scaled limits
- xy_limits: current x,y limits
- uv_st: transform canvas to scale point
- uv_xy: transform canvas to x,y point
- st_uv: transform scaled to canvas point
- st_xy: transform scaled to x,y point
- xy_st: transform x,y to scaled point
- xy_uv: transform x,y to canvas point
convert canvas coordinates to scaled coordinates (0, 1, 0, 1)
arguments:
- u, v (int)
x, y (pixel) coordinates in canvas domain.
results:
- return scaled coordinates s, t
convert canvas coordinates to x, y coordinates.
arguments:
- u, v (int)
canvas (pixel) coordinates.
results:
- return x, y coordinates
return plot window (canvas).
results:
- Returns the handle to the current plot window.
convert x, y coordinates to scaled coordinates (0, 1, 0, 1)
arguments:
- x, y (float)
x, y coordinates.
results:
- return scaled coordinates s, t
convert x, y coordinates to canvas coordinates.
arguments:
- x, y (float)
x, y coordinates.
results:
- return canvas coordinates u, v