Debian Codegraph @

docs/source/Manuals/PlotManual/ManualPlotting.rst

raw
1
2
3 =========================
4 SimPlot Manual
5 =========================
6
7
8 :Authors: Klaus Muller <[email protected]>
9 :SimPy release: |release|
10 :Web-site: http://simpy.sourceforge.net/
11 :Python-Version: 2.6 and later
12 :Date: December 2011
13
14
15 .. contents:: Contents
16 :depth: 2
17
18 The **SimPlot** plotting library has been developed for SimPy users so that
19 they can produce, view and print simple plots, without having to download and
20 install any other software package.
21
22 This manual is aimed at the SimPy applications programmer. It describes the
23 capabilities of SimPlot and its programming interface.
24
25 There are several more elaborate Open Source plotting packages downloadable from the
26 Internet which can be used from Python and therefore from SimPy. SimPlot is
27 the "quick and dirty", out-of-the-box plotting package for SimPy. If you need
28 more complex plots or publication-quality graphics, consider using e.g. Matplotlib
29 ( <http://matplotlib.sourceforge.net/>_ ).
30
31 Introduction
32 =============
33
34
35 SimPlot is a basic plotting package based on Tk/Tkinter and designed for use
36 with SimPy. It has been developed from an Open Source plotting package
37 published in John E. Grayson's excellent book 'Python and Tkinter Programming'
38 (ISBN 1-884777-81-3) which in turn was derived from Konrad Hinsen's graph
39 widget for NumPy (Numerical Python).
40
41 SimPlot provides for the generation, viewing and Postscript output of
42 a variety of plot types by SimPy programs. The data series of SimPy Monitor instances
43 can be plotted automatically.
44
45 SimPlot requires Tk/Tkinter to be installed
46 (for all major operating systems on which Python runs, the Python installation
47 already includes the installation of Tk/Tkinter, so no additional download or
48 installation is required). Test whether Tk/Tkinter is installed by running
49 'import Tkinter' on the Python interpreter command line. If you don't get
50 an error message, it is.
51
52 To write SimPlot-based programs, only a very rudimentary understanding
53 of Tk/Tkinter is required. *This manual does not attempt to teach Tk/Tkinter!*
54
55 Plotting with SimPlot - an overview
56 ====================================
57
58 Plot types and capabilities
59 ----------------------------
60
61 A simple plot program using SimPlot basically looks like::
62
63
64 # Prog1.py
65 from SimPy.SimPlot import *
66 plt=SimPlot()
67 plt.plotLine([[0,0],[1,1],[2,4],[3,9]])
68 plt.mainloop()
69
70
71 When running this program, the resulting output on Windows is
72 (the outside frame will look different on other platforms):
73
74 .. image:: /_static/images/plot_manual/Prog1.png
75
76 The program shows the basic structure of any program using
77 SimPlot:
78
79 * Line 2 imports the plotting module,
80
81 * Line 3 creates and instance of the plotting class,
82
83 * Line 4 plots a line in an x/y coordinate system,
84
85 * Line 5 starts the main loop of Tk.
86
87 The frame also shows a 'File' menu item (when clicked, it
88 offers a submenu item 'Postscript' which allows saving the plot to a
89 Postscript file.
90
91 Method *plotline* has many name parameters with default values.
92 Here is an example showing some of them (they will all be discussed
93 further down in this manual::
94
95
96 # Prog2.py
97 from SimPy.SimPlot import *
98 plt=SimPlot()
99 plt.plotLine([[0,0],[1,1],[2,4],[3,9]],title="This is prettier",
100 color="red",width=2,smooth=True)
101 plt.mainloop()
102
103
104 This produces the following plot (the outside frame is not shown):
105
106 .. image:: /_static/images/plot_manual/Prog2.png
107
108 The plot now has a title and the curve is red, wider and smooth.
109
110 In addition to *line plots*, there are three other plot-types available in SimPlot,
111 namely *stepped line plots*, *bar charts*, and *scatter diagrams*.
112
113 Here are examples of each. First, the stepped line plot::
114
115 # Prog3.py
116 from SimPy.SimPlot import *
117 plt=SimPlot()
118 plt.plotStep([[0,0],[1,1],[2,4],[3,9]],
119 color="red",width=2)
120 plt.mainloop()
121
122 which produces:
123
124 .. image:: /_static/images/plot_manual/Prog3.png
125
126 A bar chart program::
127
128 # Prog4.py
129 from SimPy.SimPlot import *
130 plt=SimPlot()
131 plt.plotBars([[0,0],[1,1],[2,4],[3,9]],
132 color="blue",width=2)
133 plt.mainloop()
134
135 which results in:
136
137 .. image:: /_static/images/plot_manual/Prog4.png
138
139 And finally, a scatter diagram::
140
141 # Prog5.py
142 from SimPy.SimPlot import *
143 plt=SimPlot()
144 plt.plotScatter([[0,0],[1,1],[2,4],[3,9]],
145 color="green",size=2,marker='triangle')
146 plt.mainloop()
147
148
149 and its output:
150
151 .. image:: /_static/images/plot_manual/Prog5.png
152
153 With a bit more involved programming, it is also possible to have
154 several plots in one diagram and to have several diagrams
155 in one Frame (just execute SimPlot.py to get these plots):
156
157 .. image:: /_static/images/plot_manual/Twoup.png
158
159 .. image:: /_static/images/plot_manual/Twodown.png
160
161 *Note: In future versions of SimPlot, this part of the API
162 will also be simplified so that it will require significantly
163 less coding.*
164
165 Plotting Monitor instances
166 ~~~~~~~~~~~~~~~~~~~~~~~~~~
167
168 Class *Monitor* is the prime data collection tool for SimPy simulations.
169 SimPlot therefore caters for easy plotting from Monitor intances.
170
171 Here is an example of a simple simulation using a Monitor::
172
173 # Monitorplot.py
174 from __future__ import generators
175 from SimPy.Simulation import *
176 from SimPy.Monitor import *
177 from SimPy.SimPlot import *
178
179 class Source(Process):
180 def __init__(self,monitor):
181 Process.__init__(self)
182 self.moni=monitor
183 self.arrived=0
184 def arrivalGenerator(self):
185 while True:
186 yield hold,self,uniform(0,20)
187 self.arrived+=1
188 self.moni.observe(self.arrived)
189
190 initialize()
191 moni=Monitor(name="Arrivals",ylab="nr arrived")
192 s=Source(moni)
193 activate(s,s.arrivalGenerator())
194 simulate(until=100)
195
196 plt=SimPlot()
197 plt.plotStep(moni,color='blue')
198 plt.mainloop()
199
200 This produces:
201
202 .. image:: /_static/images/plot_manual/Monitorplot.png
203
204
205 Simple plotting API
206 ===================
207 Overview
208 --------
209 A SimPlot application program has the following structure:
210
211 * instantiation of the **SimPlot** class
212
213 * call of one or more plotting methods
214
215 * call to the SimPlot instance's **mainloop** method
216
217 SimPlot exposes plotting methods at two levels, a *simple API*
218 with limited capabilities but ease of use, and an *advanced API*
219 with SimPlot's full capabilities, but with more involved, verbose
220 programming.
221
222 This section deals with the simple API.
223
224 SimPlot
225 --------
226
227 .. class:: SimPlot
228
229 This class provides the plotting capabilities.
230
231 plotLine
232 --------
233
234 .. classmethod:: SimPlot.plotLine(values[,optional parameters])
235
236 Generates a line plot from a list of tuples (or lists) or from a Monitor (any instance which has the attributes 'name', 'tlab', 'ylab').
237
238 :param values: (**mandatory**) a list of two-element lists (or tuples), or a Monitor instance (any instance which has the attributes 'name', 'tlab', 'ylab')
239 :type values: list or Monitor
240 :param windowsize: the plotting window size in pixels (tuple); default: (500,300)
241 :param title: the plot title ; if *values* is a Monitor, Monitor name is used if no *title* given
242 :type title: string
243 :param width: line drawing width, default: 1
244 :type width: integer or floating point
245 :param color: line colour; default: 'black'
246 :type color: Tkinter colour type
247 :param smooth: if True, makes line smooth; default: "True"
248 :type smooth: boolean
249 :param background: colour of plot background; default: 'white'
250 :type background: Tkinter colour type
251 :param xlab: ** : label on x-axis of plot; if *values* is a Monitor, Monitor *tlab* is taken; default: 'x'
252 :type xlab: string
253 :param ylab: label on y-axis of plot (string); if *values* is a Monitor, Monitor *ylab* is taken; default: 'y'
254 :param xaxis: layout of x-axis (None = omit x-axis; 'automatic' = make x-axis at least long enough to include all x-values, using round values; 'minimal' = have x-axis go *exactly* from minimal to maximal x-value provided; tuple (xlow,xhigh) = have x-axis go from xlow to xhigh); default: 'automatic'
255 :param yaxis: layout of y-axis (None = omit y-axis; 'automatic' = make y-axis at least long enough to include all y-values, using round values; 'minimal' = have y-axis go *exactly* from minimal to maximal y-value provided; tuple (ylow,yhigh) = have y-axis go from ylow to yhigh); default: 'automatic'
256 :rtype: Reference to *GraphBase* object which contains the plot.
257
258 plotStep
259 ---------
260
261 .. classmethod:: SimPlot.plotStep(values[,optional parameters])
262
263 Generates a step plot from a list of tuples (or lists) or from a Monitor (any instance which has the attributes 'name', 'tlab', 'ylab').
264 A horizontal line is drawn at a y-value until y changes, creating a step effect.
265
266 **<variable> = <SimPlotInstance>.plotStep(values[,optional parameters])**
267
268 :param values: (**mandatory**) a list of two-element lists (or tuples), or a Monitor instance (any instance which has the attributes 'name', 'tlab', 'ylab')
269
270
271 Optional parameters with defaults:
272 - **windowsize=(500,300),** : the plotting window size in pixels (tuple)
273
274 - **title=""** : the plot title (string); if **values** is a Monitor, Monitor name is used if no **title** given
275
276 - **width=1** : line drawing width (integer or floating point)
277
278 - **color='black'** : line colour (Tkinter colour type; see section on Colours in SimPlot)
279
280 - **background='white'** : colour of plot background (Tkinter colour type; see section on Colours in SimPlot)
281
282 - **xlab='x'** : label on x-axis of plot (string); if **values** is a Monitor, Monitor *tlab* is taken
283
284 - **ylab='y'** : label on y-axis of plot (string); if **values** is a Monitor, Monitor *ylab* is taken
285
286 - **xaxis='automatic'** : layout of x-axis (None = omit x-axis; 'automatic' = make x-axis at least long enough to include all x-values, using round values; 'minimal' = have x-axis go *exactly* from minimal to maximal x-value provided; tuple (xlow,xhigh) = have x-axis go from xlow to xhigh)
287
288 - **yaxis='automatic'** : layout of y-axis (None = omit y-axis; 'automatic' = make y-axis at least long enough to include all y-values, using round values; 'minimal' = have y-axis go *exactly* from minimal to maximal y-value provided; tuple (ylow,yhigh) = have y-axis go from ylow to yhigh)
289
290 Return value:
291 Reference to *GraphBase* object which contains the plot.
292
293 plotBars
294 --------
295
296 Generates a bar chart plot from a list of tuples (or lists) or from a Monitor.
297
298 Call:
299 **<SimPlotInstance>.plotBars(values[,optional parameters])**
300
301 **<variable> = <SimPlotInstance>.plotBars(values[,optional parameters])**
302
303 Mandatory parameters:
304 - **values** : a list of two-element lists (or tuples), or a Monitor instance
305
306 Optional parameters with defaults:
307 - **windowsize=(500,300),** : the plotting window size in pixels (tuple)
308
309 - **title=''** : the plot title (string); if **values** is a Monitor, Monitor name is used if no **title** given
310
311 - **width=1** : outline drawing width (integer or floating point)
312
313 - **color='black'** : outline colour (Tkinter colour type; see section on Colours in SimPlot)
314
315 - **fillcolor='black'** : colour with which bars are filled (Tkinter colour type; see section on Colours in SimPlot)
316
317 - **fillstyle=''** : density of fill (default=100%; Tkinter bitmap)
318
319 - **outline='black"** : colour of bar outline ((Tkinter colour type; see section on Colours in SimPlot)
320
321 - **background='white'** : colour of plot background (Tkinter colour type; see section on Colours in SimPlot)
322
323 - **xlab='x'** : label on x-axis of plot (string); if **values** is a Monitor, Monitor *tlab* is taken
324
325 - **ylab='y'** : label on y-axis of plot (string); if **values** is a Monitor, Monitor *ylab* is taken
326
327 - **xaxis='automatic'** : layout of x-axis (None = omit x-axis; 'automatic' = make x-axis at least long enough to include all x-values, using round values; 'minimal' = have x-axis go *exactly* from minimal to maximal x-value provided; tuple (xlow,xhigh) = have x-axis go from xlow to xhigh)
328
329 - **yaxis='automatic'** : layout of y-axis (None = omit y-axis; 'automatic' = make y-axis at least long enough to include all y-values, using round values; 'minimal' = have y-axis go *exactly* from minimal to maximal y-value provided; tuple (ylow,yhigh) = have y-axis go from ylow to yhigh)
330
331
332 Return value:
333 Reference to *GraphBase* object which contains the plot.
334
335 plotHistogram
336 -------------
337
338 Generates a histogram plot from a Histogram or a Histogram-like list or tuple.
339 A SimPy Histogram instance is a list with items of two elements. It has
340 n+2 bins of equal width, sorted by the first element, containing integer values
341 == the counts of the bins. The first bin is the 'under' bin, the last the
342 'over' bin.
343 Histogram objects are produced from Monitor objects by calling the Monitor
344 method *histogram()*.
345
346 Call:
347 **<SimPlotInstance>.plotHistogram(values[,optional parameters])**
348
349 **<variable> = <SimPlotInstance>.plotHistogram(values[,optional parameters])**
350
351 Mandatory parameters:
352 - **values** : a list of two-element lists (or tuples), or a Monitor instance
353
354 Optional parameters with defaults:
355 - **windowsize=(500,300)** : the plotting window size in pixels (tuple)
356
357 - **title=''** : the plot title (string); if **values** is a Monitor, Monitor name is used if no **title** given
358
359 - **width=1** : line drawing width (integer or floating point)
360
361 - **color='black'** : line colour (Tkinter colour type; see section on Colours in SimPlot)
362
363 - **background='white'** : colour of plot background (Tkinter colour type; see section on Colours in SimPlot)
364
365 - **xlab='x'** : label on x-axis of plot (string)
366
367 - **ylab='y'** : label on y-axis of plot (string)
368
369 - **xaxis='automatic'** : layout of x-axis (None = omit x-axis; 'automatic' = make x-axis at least long enough to include all x-values, using round values; 'minimal' = have x-axis go *exactly* from minimal to maximal x-value provided; tuple (xlow,xhigh) = have x-axis go from xlow to xhigh)
370
371 - **yaxis='automatic'** : layout of y-axis (None = omit y-axis; 'automatic' = make y-axis at least long enough to include all y-values, using round values; 'minimal' = have y-axis go *exactly* from minimal to maximal y-value provided; tuple (ylow,yhigh) = have y-axis go from ylow to yhigh)
372
373
374 plotScatter
375 -----------
376
377 Generates a scatter diagram plot from a list of tuples (or lists) or from a Monitor.
378
379 Call:
380 **<SimPlotInstance>.plotScatter(values[,optional parameters])**
381
382 **variable = <SimPlotInstance>. plotScatter(values[,optional parameters])**
383
384 Mandatory parameters:
385 - **values** : a list of two-element lists (or tuples), or a Monitor instance
386
387 Optional parameters with defaults:
388 - **windowsize=(500,300),** : the plotting window size in pixels (tuple)
389
390 - **title=''** : the plot title (string); if **values** is a Monitor, Monitor name is used if no **title** given
391
392 - **marker='circle'** : symbol type (literal; values supported: 'circle, 'dot', 'square', 'triangle, 'triangle_down', 'cross', 'plus')
393
394 - **width=1** : line drawing width (integer or floating point)
395
396 - **color='black'** : line colour (Tkinter colour type; see section on Colours in SimPlot)
397
398 - **fillcolor='black'** : colour with which bars are filled (Tkinter colour type; see section on Colours in SimPlot)
399
400 - **fillstyle=''** : density of fill (default=100%; Tkinter bitmap)
401
402 - **outline='black'** : colour of marker outline ((Tkinter colour type; see section on Colours in SimPlot)
403
404 - **background='white'** : colour of plot background (Tkinter colour type; see section on Colours in SimPlot)
405
406 - **xlab='x'** : label on x-axis of plot (string); if **values** is a Monitor, Monitor *tlab* is taken
407
408 - **ylab='y'** : label on y-axis of plot (string); if **values** is a Monitor, Monitor *ylab* is taken
409
410 - **xaxis='automatic'** : layout of x-axis (None = omit x-axis; 'automatic' = make x-axis at least long enough to include all x-values, using round values; 'minimal' = have x-axis go *exactly* from minimal to maximal x-value provided; tuple (xlow,xhigh) = have x-axis go from xlow to xhigh)
411
412 - **yaxis='automatic'** : layout of y-axis (None = omit y-axis; 'automatic' = make y-axis at least long enough to include all y-values, using round values; 'minimal' = have y-axis go *exactly* from minimal to maximal y-value provided; tuple (ylow,yhigh) = have y-axis go from ylow to yhigh)
413
414
415 Return value:
416 Reference to *GraphBase* object which contains the plot.
417
418 postscr
419 -------
420 Saves Postscript output from a plot to a file. After e.g. ``aPlot=plotLine([0,1],[3,4])``, ``aPlot.postscr("c:\\myplot.ps")``
421 outputs the line plot in Postscript to file c:\\myplot.ps.
422
423 Call:
424 **<plotinstance>.postscr([optional parameter])** (with <plotinstance> being a reference to the *GraphBase* object which contains the plot)
425
426 Mandatory parameters:
427 None.
428
429 Optional parameters with defaults:
430 - **"<filename>"** : name of file (complete path) to which Postscript output is written. If omitted, a dialog asking the user for a filename pops up.
431
432 Return value:
433 None.
434
435
436 Advanced plotting API
437 =====================
438 Overview
439 --------
440 The advanced SimPlot API is more verbose than the simple one, but it offers more flexibility and power. The detailed structure of a program using that API is:
441
442 1. make an instance of SimPlot (this initializes Tk and generates a Tk Toplevel container <instance>.root which points at the Tk object.)
443 2. (optional) make other Tk container(s)
444 3. (optional) give the container a title
445 4. make one or more plot objects (the lines or other figures to plot)
446 5. put the plot objects into a GraphObject (this does the necessary scaling)
447 6. make a Tk container (e.g. a Frame widget) in the previous container (from step 1 or 2)
448 7. make a background (with title, axes, frame, etc.) in that container for the GraphObject to be drawn against (i.e., create the graph widget and associate the GraphObject with it)
449 8. instruct the Tk geometry manager (pack or grid) where to put the background in the Tk container
450 9. draw the GraphObject against the background
451 10. instruct the Tk geometry manager concerning the container from step 6
452 11. (optional) save plot as Postscript file
453 12. start the Tk mainloop
454
455 An example::
456
457 # AdvancedAPI.py
458 from SimPy. SimPlot import *
459 plt=SimPlot() # step 1
460 plt.root.title("Advanced API example") # step 3
461 line=plt.makeLine([[0,42],[1,1],[4,16]]) # step 4
462 bar=plt.makeBars([[0,42],[1,1],[4,16]],
463 color='blue') # step 4
464 sym=plt.makeSymbols([[1,1]],marker="triangle",
465 size=3,fillcolor="red") # step 4
466 obj=plt.makeGraphObjects([line,bar,sym]) # step 5
467 frame=Frame(plt.root) # step 6
468 graph=plt.makeGraphBase(frame,500,300,
469 title="Line and bars") # step 7
470 graph.pack() # step 8
471 graph.draw(obj) # step 9
472 frame.pack() # step 10
473 graph.postscr() # step 11
474 plt.mainloop() # step 12
475
476 Which generates:
477
478 .. image:: /_static/images/plot_manual/AdvancedAPI.png
479
480 Clearly, this level API is more verbose, but allows putting several diagrams with different
481 plot types into one plot, or putting putting several plots into one frame (side by side, vertically,
482 or in table fashion).
483
484 title
485 -----
486 Assign a title to appear in the container's title bar. (This is a method exposed by a Tk Toplevel container.)
487
488 Call:
489 **<rootInstance>.title(title)**
490
491 Mandatory parameters:
492 - **title** : the title to appear in the container's title bar (string)
493
494 Optional parameters:
495 None.
496
497 Return value:
498 None.
499
500 makeLine
501 ----------
502 Generates a line plot object from a list of tuples (or lists).
503
504 Call:
505 **<variable> = <SimPlotInstance>.makeLine(values[,optional parameters])**
506
507 Mandatory parameters:
508 - **values** : a list of two-element lists (or tuples)
509
510 Optional parameters:
511 - **color = 'black'** : line colour (Tk colour value)
512 - **width = 1** : line width (integer or float)
513 - **smooth = False** : smooth line if True (boolean)
514 - **splinesteps = 12** : number of spline steps for smoothing line (integer); the higher, the better the line follows the points provided
515
516 Return value:
517 Reference to a line plot object (GraphLine)
518
519 makeStep
520 ----------
521 Generates a line plot object from a list of tuples (or lists).
522 A horizontal line is generated at a y-value until y changes, creating a step effect.
523
524 Call:
525 **<variable> = <SimPlotInstance>.makeStep(values[,optional parameters])**
526
527 Mandatory parameters:
528 - **values** : a list of two-element lists (or tuples)
529
530 Optional parameters:
531 - **color = 'black'** : line colour (Tk colour value)
532 - **width = 1** : line width (integer or float)
533
534 Return value:
535 Reference to a line plot object (GraphLine)
536
537 makeSymbols
538 -------------
539 Generates a scatter diagram plot object with markers from a list of tuples (or lists).
540
541 Call:
542 **<variable> = <SimPlotInstance>.makeSymbols(values[,optional parameters])**
543
544 Mandatory parameters:
545 - **values** : a list of two-element lists (or tuples)
546
547 Optional parameters:
548 - **marker='circle'** : symbol type (literal; values supported: 'circle, 'dot', 'square', 'triangle, 'triangle_down', 'cross', 'plus')
549
550 - **width=1** : line drawing width (integer or floating point)
551
552 - **color='black'** : line colour (Tkinter colour type; see section on Colours in SimPlot)
553
554 - **fillcolor='black'** : colour with which bars are filled (Tkinter colour type; see section on Colours in SimPlot)
555
556 - **fillstyle=''** : density of fill (default=100%; Tkinter bitmap)
557
558 - **outline='black'** : colour of marker outline ((Tkinter colour type; see section on Colours in SimPlot)
559
560 Return value:
561 Reference to a scatter plot object (GraphSymbols)
562
563 makeBars
564 --------
565 Generates a bar chart plot object with markers from a list of tuples (or lists).
566
567 Call:
568 **<variable> = <SimPlotInstance>.makeBars(values[,optional parameters])**
569
570 Mandatory parameters:
571 - **values** : a list of two-element lists (or tuples)
572
573 Optional parameters:
574 - **width=1** : width of bars (integer or floating point)
575
576 - **color='black'** : bar colour (Tkinter colour type; see section on Colours in SimPlot)
577
578 - **fillcolor='black'** : colour with which bars are filled (Tkinter colour type; see section on Colours in SimPlot)
579
580 - **fillstyle=''** : density of fill (default=100%; Tkinter bitmap)
581
582 - **outline='black"** : colour of bar outline ((Tkinter colour type; see section on Colours in SimPlot)
583
584 Return value:
585 Reference to a bar chart plot object (GraphSymbols)
586
587 makeHistogram
588 -------------
589 Generates a histogram plot from a Histogram or a Histogram-like list or tuple.
590 A SimPy Histogram instance is a list with items of two elements. It has
591 n+2 bins of equal width, sorted by the first element, containing integer values
592 == the counts of the bins. The first bin is the 'under' bin, the last the
593 'over' bin.
594 Histogram objects are produced from Monitor objects by calling the Monitor
595 method *histogram()*.
596
597 Call:
598 **<variable> = <SimPlotInstance>.makeBars(values[,optional parameters])**
599
600 Mandatory parameters:
601 - **values** : a Histogram-like object
602
603 Optional parameters:
604 - **width=1** : width of line (integer or floating point)
605
606 - **color='black'** : line colour (Tkinter colour type; see section on Colours in SimPlot)
607
608
609 makeGraphObjects
610 ----------------
611 Combines one or mor plot objects into one plottable GraphObject.
612
613 Call:
614 **<variable> = <SimPlotInstance>.makeGraphObjects(list_of_plotObjects)**
615
616 Mandatory parameters:
617 - **list_of_plotObjects** : a list of plot objects
618
619 Optional parameters:
620 None
621
622 Return value:
623 Reference to a GraphObject
624
625 makeGraphBase
626 -------------
627 Generates a canvas widget in its Tk container widget (such as a Frame) with the plot's background (title, axes, axis labels).
628
629 Call:
630 **<variable> = <SimPlotInstance>.makeGraphBase(master, width, height [,optional parameters])**
631
632 Mandatory parameters:
633 - **master** : container widget for graph widget
634
635 - **width** : width of graph widget in pixels (positive integer)
636
637 - **height** : height of graph widget in pixels (positive integer)
638
639 Optional parameters:
640 - **background='white'** : colour of plot background (Tk colour value)
641 - **title=""** : title of plot (string)
642 - **xtitle=''** : label on x-axis (string)
643 - **ytitle=''** : label on y-axis (string)
644
645 Return value:
646 Reference to a GraphBase object (graph widget)
647
648 pack
649 ----
650 Controls how graph widget is arranged in its master container.
651 (Inherited from Tk Packer geometry manager.)
652
653 Call:
654 **<GraphBaseInstance>.pack([optional parameters])**
655
656 Mandatory parameters:
657 None.
658
659 Optional parameters:
660 - **side** : where to place graph widget (side=LEFT: to the left; side=TOP: at the top; Tk Packer literals)
661
662 - **fill** : controls whether graph fills available space in window (fill=BOTH: fills in both directions; fill=X: horizontal stretching; fill=Y: vertical stretching)
663
664 - **expand=NO** : controls whether Packer expands graph widget when window is resized (expand=TRUE: widget may expand to fill available space)
665
666 Return value:
667 None
668
669 draw
670 ----
671 Draws the plot background and the lines/curves in it.
672
673 Call:
674
675 **<GraphBaseInstance>.draw(graph,[optional parameters])**
676
677 Mandatory parameters:
678 - **graphics** : graph widget (GraphBase) instance
679
680 Optional parameters:
681 - **xaxis='automatic'** : controls appearance of x-axis (None: no x-axis; "minimal": axis runs exactly from minimal to maximal x-value; "automatic" : x-axis starts at 0 and includes maximal x-value; tuple (xlow,xhigh) = have x-axis go from xlow to xhigh)
682
683 - **yaxis='automatic'** : controls appearance of y-axis (None: no y-axis;"minimal": axis runs exactly from minimal to maximal y-value; "automatic" : y-axis starts at 0 and includes maximal y-value; tuple (ylow,yhigh) = have y-axis go from ylow to yhigh
684
685 Return value:
686 None
687
688 postscr
689 -------
690 After call to draw , saves Postscript output from a plot to a file.
691
692 Call:
693 **<GraphBaseInstance>.postscr([optional parameter])**
694
695 Mandatory parameters:
696 None.
697
698 Optional parameters with defaults:
699 - **"filename"** : name of file (complete path) to which Postscript output is written. If omitted, a dialog asking the user for a filename pops up.
700
701 Return value:
702 None.
703
704
705 Colours in SimPlot
706 ==================
707 Colours in SimPlot are defined by Tk. The Tk colour model is RGB. The simplest way to identify a colour
708 is to use one of the hundreds of Tk-defined literals such as "black", "aquamarine", or even "BlanchedAlmond".
709 See the `Tk colour page`_ for definitions.
710
711 .. _`Tk colour page`: ../../_static/Tkcolors.htm
712