some updates to the docu
[PyX/mjg.git] / manual / graph.tex
blobc0099fce027edf02f2d3d2e3a67811db429f7155
1 \chapter{Graphs}
2 \label{graph}
4 \section{Introduction} % {{{
5 \PyX{} can be used for data and function plotting. At present
6 x-y-graphs and x-y-z-graphs are supported only. However, the component
7 architecture of the graph system described in section
8 \ref{graph:components} allows for additional graph geometries while
9 reusing most of the existing components.
11 Creating a graph splits into two basic steps. First you have to create
12 a graph instance. The most simple form would look like:
13 \begin{verbatim}
14 from pyx import *
15 g = graph.graphxy(width=8)
16 \end{verbatim}
17 The graph instance \code{g} created in this example can then be used
18 to actually plot something into the graph. Suppose you have some data
19 in a file \file{graph.dat} you want to plot. The content of the file
20 could look like:
21 \verbatiminput{graph.dat}
22 To plot these data into the graph \code{g} you must perform:
23 \begin{verbatim}
24 g.plot(graph.data.file("graph.dat", x=1, y=2))
25 \end{verbatim}
26 The method \method{plot()} takes the data to be plotted and optionally
27 a list of graph styles to be used to plot the data. When no styles are
28 provided, a default style defined by the data instance is used. For
29 data read from a file by an instance of \class{graph.data.file}, the
30 default are symbols. When instantiating \class{graph.data.file}, you
31 not only specify the file name, but also a mapping from columns to
32 axis names and other information the styles might make use of
33 (\emph{e.g.} data for error bars to be used by the errorbar style).
35 While the graph is already created by that, we still need to perform a
36 write of the result into a file. Since the graph instance is a canvas,
37 we can just call its \method{writeEPSfile()} method.
38 \begin{verbatim}
39 g.writeEPSfile("graph")
40 \end{verbatim}
41 The result \file{graph.eps} is shown in figure~\ref{fig:graph}.
43 \begin{figure}[ht]
44 \centerline{\includegraphics{graph}}
45 \caption[A minimalistic plot for the data from a file.]{A minimalistic plot for the data from file \file{graph.dat}.}
46 \label{fig:graph}
47 \end{figure}
49 Instead of plotting data from a file, other data source are available
50 as well. For example function data is created and placed into
51 \method{plot()} by the following line:
52 \begin{verbatim}
53 g.plot(graph.data.function("y(x)=x**2"))
54 \end{verbatim}
55 You can plot different data in a single graph by calling
56 \method{plot()} several times before \method{writeEPSfile()} or
57 \method{writePDFfile()}. Note that a calling \method{plot()} will fail
58 once a graph was forced to ``finish'' itself. This happens
59 automatically, when the graph is written to a file. Thus it is not an
60 option to call \method{plot()} after \method{writeEPSfile()} or
61 \method{writePDFfile()}. The topic of the finalization of a graph is
62 addressed in more detail in section~\ref{graph:graph}. As you can see
63 in figure~\ref{fig:graph2}, a function is plotted as a line by
64 default.
66 \begin{figure}[ht]
67 \centerline{\includegraphics{graph2}}
68 \caption{Plotting data from a file together with a function.}
69 \label{fig:graph2}
70 \end{figure}
72 While the axes ranges got adjusted automatically in the previous
73 example, they might be fixed by keyword options in axes constructors.
74 Plotting only a function will need such a setting at least in the
75 variable coordinate. The following code also shows how to set a
76 logathmic axis in y-direction:
78 \verbatiminput{graph3.py}
80 The result is shown in figure~\ref{fig:graph3}.
82 \begin{figure}[ht]
83 \centerline{\includegraphics{graph3}}
84 \caption{Plotting a function for a given axis range and use a
85 logarithmic y-axis.}
86 \label{fig:graph3}
87 \end{figure} % }}}
89 \section{Component architecture} % {{{
90 \label{graph:components}
92 Creating a graph involves a variety of tasks, which thus can be
93 separated into components without significant additional costs.
94 This structure manifests itself also in the \PyX{} source, where there
95 are different modules for the different tasks. They interact by some
96 well-defined interfaces. They certainly have to be completed and
97 stabilized in their details, but the basic structure came up in the
98 continuous development quite clearly. The basic parts of a graph are:
100 \begin{definitions}
101 \term{graph}
102 Defines the geometry of the graph by means of graph coordinates with
103 range [0:1]. Keeps lists of plotted data, axes \emph{etc.}
104 \term{data}
105 Produces or prepares data to be plotted in graphs.
106 \term{style}
107 Performs the plotting of the data into the graph. It gets data,
108 converts them via the axes into graph coordinates and uses the graph
109 to finally plot the data with respect to the graph geometry methods.
110 \term{key}
111 Responsible for the graph keys.
112 \term{axis}
113 Creates axes for the graph, which take care of the mapping from data
114 values to graph coordinates. Because axes are also responsible for
115 creating ticks and labels, showing up in the graph themselves and
116 other things, this task is splitted into several independent
117 subtasks. Axes are discussed separately in chapter~\ref{axis}.
118 \end{definitions} % }}}
120 \section{Module \module{graph.graph}: Graphs} % {{{
121 \label{graph:graph}
123 \declaremodule{}{graph.graph}
124 \modulesynopsis{Graph geometry}
126 The classes \class{graphxy} and \class{graphxyz} are part of the
127 module \module{graph.graph}. However, there are shortcuts to access
128 the classes via \code{graph.graphxy} and \code{graph.graphxyz},
129 respectively.
131 \begin{classdesc}{graphxy}{xpos=0, ypos=0, width=None, height=None,
132 ratio=goldenmean, key=None, backgroundattrs=None,
133 axesdist=0.8*unit.v\_cm, xaxisat=None, yaxisat=None, **axes}
134 This class provides an x-y-graph. A graph instance is also a fully
135 functional canvas.
137 The position of the graph on its own canvas is specified by
138 \var{xpos} and \var{ypos}. The size of the graph is specified by
139 \var{width}, \var{height}, and \var{ratio}. These parameters define
140 the size of the graph area not taking into account the additional
141 space needed for the axes. Note that you have to specify at least
142 \var{width} or \var{height}. \var{ratio} will be used as the ratio
143 between \var{width} and \var{height} when only one of these is
144 provided.
146 \var{key} can be set to a \class{graph.key.key} instance to create
147 an automatic graph key. \code{None} omits the graph key.
149 \var{backgroundattrs} is a list of attributes for drawing the
150 background of the graph. Allowed are decorators, strokestyles, and
151 fillstyles. \code{None} disables background drawing.
153 \var{axisdist} is the distance between axes drawn at the same side
154 of a graph.
156 \var{xaxisat} and \var{yaxisat} specify a value at the y and x axis,
157 where the corresponding axis should be moved to. It's a shortcut for
158 corresonding calls of \method{axisatv()} described below. Moving an
159 axis by \var{xaxisat} or \var{yaxisat} disables the automatic
160 creation of a linked axis at the opposite side of the graph.
162 \var{**axes} receives axes instances. Allowed keywords (axes names)
163 are \code{x}, \code{x2}, \code{x3}, \emph{etc.} and \code{y},
164 \code{y2}, \code{y3}, \emph{etc.} When not providing an \code{x} or
165 \code{y} axis, linear axes instances will be used automatically.
166 When not providing a \code{x2} or \code{y2} axis, linked axes to the
167 \code{x} and \code{y} axes are created automatically and \emph{vice
168 versa}. As an exception, a linked axis is not created automatically
169 when the axis is placed at a specific position by \var{xaxisat} or
170 \var{yaxisat}. You can disable the automatic creation of axes by
171 setting the linked axes to \code{None}. The even numbered axes are
172 plotted at the top (\code{x} axes) and right (\code{y} axes) while
173 the others are plotted at the bottom (\code{x} axes) and left
174 (\code{y} axes) in ascending order each.
175 \end{classdesc}
177 Some instance attributes might be useful for outside read-access.
178 Those are:
180 \begin{memberdesc}{axes}
181 A dictionary mapping axes names to the \class{anchoredaxis} instances.
182 \end{memberdesc}
184 To actually plot something into the graph, the following instance
185 method \method{plot()} is provided:
187 \begin{methoddesc}{plot}{data, styles=None}
188 Adds \var{data} to the list of data to be plotted. Sets \var{styles}
189 to be used for plotting the data. When \var{styles} is \code{None},
190 the default styles for the data as provided by \var{data} is used.
192 \var{data} should be an instance of any of the data described in
193 section~\ref{graph:data}.
195 When the same combination of styles (\emph{i.e.} the same
196 references) are used several times within the same graph instance,
197 the styles are kindly asked by the graph to iterate their
198 appearance. Its up to the styles how this is performed.
200 Instead of calling the plot method several times with different
201 \var{data} but the same style, you can use a list (or something
202 iterateable) for \var{data}.
203 \end{methoddesc}
205 While a graph instance only collects data initially, at a certain
206 point it must create the whole plot. Once this is done, further calls
207 of \method{plot()} will fail. Usually you do not need to take care
208 about the finalization of the graph, because it happens automatically
209 once you write the plot into a file. However, sometimes position
210 methods (described below) are nice to be accessible. For that, at
211 least the layout of the graph must have been finished. By calling the
212 \method{do}-methods yourself you can also alter the order in which the
213 graph components are plotted. Multiple calls to any of the
214 \method{do}-methods have no effect (only the first call counts). The
215 orginal order in which the \method{do}-methods are called is:
217 \begin{methoddesc}{dolayout}{}
218 Fixes the layout of the graph. As part of this work, the ranges of
219 the axes are fitted to the data when the axes ranges are allowed to
220 adjust themselves to the data ranges. The other \method{do}-methods
221 ensure, that this method is always called first.
222 \end{methoddesc}
224 \begin{methoddesc}{dobackground}{}
225 Draws the background.
226 \end{methoddesc}
228 \begin{methoddesc}{doaxes}{}
229 Inserts the axes.
230 \end{methoddesc}
232 \begin{methoddesc}{doplotitem}{plotitem}
233 Plots the plotitem as returned by the graphs plot method.
234 \end{methoddesc}
236 \begin{methoddesc}{doplot}{}
237 Plots all (remaining) plotitems.
238 \end{methoddesc}
240 \begin{methoddesc}{dokeyitem}{}
241 Inserts a plotitem in the graph key as returned by the graphs plot method.
242 \end{methoddesc}
244 \begin{methoddesc}{dokey}{}
245 Inserts the graph key.
246 \end{methoddesc}
248 \begin{methoddesc}{finish}{}
249 Finishes the graph by calling all pending \method{do}-methods. This
250 is done automatically, when the output is created.
251 \end{methoddesc}
253 The graph provides some methods to access its geometry:
255 \begin{methoddesc}{pos}{x, y, xaxis=None, yaxis=None}
256 Returns the given point at \var{x} and \var{y} as a tuple
257 \code{(xpos, ypos)} at the graph canvas. \var{x} and \var{y} are
258 anchoredaxis instances for the two axes \var{xaxis} and \var{yaxis}.
259 When \var{xaxis} or \var{yaxis} are \code{None}, the axes with names
260 \code{x} and \code{y} are used. This method fails if called before
261 \method{dolayout()}.
262 \end{methoddesc}
264 \begin{methoddesc}{vpos}{vx, vy}
265 Returns the given point at \var{vx} and \var{vy} as a tuple
266 \code{(xpos, ypos)} at the graph canvas. \var{vx} and \var{vy} are
267 graph coordinates with range [0:1].
268 \end{methoddesc}
270 \begin{methoddesc}{vgeodesic}{vx1, vy1, vx2, vy2}
271 Returns the geodesic between points \var{vx1}, \var{vy1} and
272 \var{vx2}, \var{vy2} as a path. All parameters are in graph
273 coordinates with range [0:1]. For \class{graphxy} this is a straight
274 line.
275 \end{methoddesc}
277 \begin{methoddesc}{vgeodesic\_el}{vx1, vy1, vx2, vy2}
278 Like \method{vgeodesic()} but this method returns the path element to
279 connect the two points.
280 \end{methoddesc}
282 % dirty hack to add a whole list of methods to the index:
283 \index{xbasepath()@\texttt{xbasepath()} (graphxy method)}
284 \index{xvbasepath()@\texttt{xvbasepath()} (graphxy method)}
285 \index{xgridpath()@\texttt{xgridpath()} (graphxy method)}
286 \index{xvgridpath()@\texttt{xvgridpath()} (graphxy method)}
287 \index{xtickpoint()@\texttt{xtickpoint()} (graphxy method)}
288 \index{xvtickpoint()@\texttt{xvtickpoint()} (graphxy method)}
289 \index{xtickdirection()@\texttt{xtickdirection()} (graphxy method)}
290 \index{xvtickdirection()@\texttt{xvtickdirection()} (graphxy method)}
291 \index{ybasepath()@\texttt{ybasepath()} (graphxy method)}
292 \index{yvbasepath()@\texttt{yvbasepath()} (graphxy method)}
293 \index{ygridpath()@\texttt{ygridpath()} (graphxy method)}
294 \index{yvgridpath()@\texttt{yvgridpath()} (graphxy method)}
295 \index{ytickpoint()@\texttt{ytickpoint()} (graphxy method)}
296 \index{yvtickpoint()@\texttt{yvtickpoint()} (graphxy method)}
297 \index{ytickdirection()@\texttt{ytickdirection()} (graphxy method)}
298 \index{yvtickdirection()@\texttt{yvtickdirection()} (graphxy method)}
300 Further geometry information is available by the \member{axes}
301 instance variable, with is a dictionary mapping axis names to
302 \class{anchoredaxis} instances. Shortcuts to the anchoredaxis
303 positioner methods for the \code{x}- and \code{y}-axis become
304 available after \method{dolayout()} as \class{graphxy} methods
305 \code{Xbasepath}, \code{Xvbasepath}, \code{Xgridpath},
306 \code{Xvgridpath}, \code{Xtickpoint}, \code{Xvtickpoint},
307 \code{Xtickdirection}, and \code{Xvtickdirection} where the prefix
308 \code{X} stands for \code{x} and \code{y}.
310 \begin{methoddesc}{axistrafo}{axis, t}
311 This method can be used to apply a transformation \var{t} to an
312 \class{anchoredaxis} instance \var{axis} to modify the axis position
313 and the like. This method fails when called on a not yet finished
314 axis, i.e. it should be used after \method{dolayout()}.
315 \end{methoddesc}
317 \begin{methoddesc}{axisatv}{axis, v}
318 This method calls \method{axistrafo()} with a transformation to move
319 the axis \var{axis} to a graph position \var{v} (in graph
320 coordinates).
321 \end{methoddesc}
323 The class \class{graphxyz} is very similar to the \class{graphxy}
324 class, except for its additional dimension. In the following
325 documentation only the differences to the \class{graphxy} class are
326 described.
328 \begin{classdesc}{graphxyz}{xpos=0, ypos=0, size=None,
329 xscale=1, yscale=1, zscale=1/goldenmean,
330 projector=central(10, -30, 30), key=None,
331 **axes}
332 This class provides an x-y-z-graph.
334 The position of the graph on its own canvas is specified by
335 \var{xpos} and \var{ypos}. The size of the graph is specified by
336 \var{size} and the length factors \var{xscale}, \var{yscale}, and
337 \var{zscale}. The final size of the graph depends on the projector
338 \var{projector}, which is called with \code{x}, \code{y}, and
339 \code{z} values up to \var{xscale}, \var{yscale}, and \var{zscale}
340 respectively and scaling the result by \var{size}. For a parallel
341 projector changing \var{size} is thus identical to changing
342 \var{xscale}, \var{yscale}, and \var{zscale} by the same factor. For
343 the central projector the projectors internal distance would also
344 need to be changed by this factor. Thus \var{size} changes the size
345 of the whole graph without changing the projection.
347 \var{projector} defines the conversion of 3d coordinates to 2d
348 coordinates. It can be an instance of \class{central} or
349 \class{parallel} described below.
351 \var{**axes} receives axes instances as for \class{graphxyz}. The
352 graphxyz allows for 4 axes per graph dimension \code{x}, \code{x2},
353 \code{x3}, \code{x4}, \code{y}, \code{y2}, \code{y3}, \code{y4},
354 \code{z}, \code{z2}, \code{z3}, and \code{z4}. The x-y-plane is the
355 horizontal plane at the bottom and the \code{x}, \code{x2},
356 \code{y}, and \code{y2} axes are placed at the boundary of this
357 plane with \code{x} and \code{y} always being in front. \code{x3},
358 \code{x4}, \code{y3}, and \code{y4} are handled similar, but for the
359 top plane of the graph. The \code{z} axis is placed at the origin of
360 the \code{x} and \code{y} dimension, whereas \code{z2} is placed at
361 the final point of the \code{x} dimension, \code{z3} at the final
362 point of the \code{y} dimension and \code{z4} at the final point of
363 the \code{x} and \code{y} dimension together.
364 \end{classdesc}
366 \begin{memberdesc}{central}
367 The central attribute of the graphxyz is the \class{central} class.
368 See the class description below.
369 \end{memberdesc}
371 \begin{memberdesc}{parallel}
372 The parallel attribute of the graphxyz is the \class{parallel} class.
373 See the class description below.
374 \end{memberdesc}
376 Regarding the 3d to 2d transformation the methods \method{pos},
377 \method{vpos}, \method{vgeodesic}, and \method{vgeodesic\_el} are
378 available as for class \class{graphxy} and just take an additional
379 argument for the dimension. Note that a similar transformation method
380 (3d to 2d) is available as part of the projector as well already, but
381 only the graph acknowledges its size, the scaling and the internal
382 tranformation of the graph coordinates to the scaled coordinates. As
383 the projector also implements a \method{zindex} and a \method{angle}
384 method, those are also available at the graph level in the graph
385 coordinate variant (i.e. having an additional v in its name and using
386 values from 0 to 1 per dimension).
388 \begin{methoddesc}{vzindex}{vx, vy, vz}
389 The depths of the point defined by \var{vx}, \var{vy}, and \var{vz}
390 scaled to a range [-1:1] where 1 in closed to the viewer. All
391 arguments passed to the method are in graph coordinates with range
392 [0:1].
393 \end{methoddesc}
395 \begin{methoddesc}{vangle}{vx1, vy1, vz1, vx2, vy2, vz2, vx3, vy3, vz3}
396 The cosine of the angle of the view ray thru point \code{(vx1, vy1,
397 vz1)} and the plane defined by the points \code{(vx1, vy1, vz1)},
398 \code{(vx2, vy2, vz2)}, and \code{(vx3, vy3, vz3)}. All arguments
399 passed to the method are in graph coordinates with range [0:1].
400 \end{methoddesc}
402 There are two projector classes \class{central} and \class{parallel}:
404 \begin{classdesc}{central}{distance, phi, theta, anglefactor=math.pi/180}
405 Instances of this class implement a central projection for the given
406 parameters.
408 \var{distance} is the distance of the viewer from the origin. Note
409 that the \class{graphxyz} class uses the range \code{-xscale} to
410 \code{xscale}, \code{-yscale} to \code{yscale}, and \code{-zscale}
411 to \code{zscale} for the coordinates \code{x}, \code{y}, and
412 \code{z}. As those scales are of the order of one (by default), the
413 distance should be of the order of 10 to give nice results. Smaller
414 distances increase the central projection character while for huge
415 distances the central projection becomes identical to the parallel
416 projection.
418 \code{phi} is the angle of the viewer in the x-y-plane and
419 \code{theta} is the angle of the viewer to the x-y-plane. The
420 standard notation for spheric coordinates are used. The angles are
421 multiplied by \var{anglefactor} which is initialized to do a degree
422 in radiant transformation such that you can specify \code{phi} and
423 \code{theta} in degree while the internal computation is always done
424 in radiants.
425 \end{classdesc}
427 \begin{classdesc}{parallel}{phi, theta, anglefactor=math.pi/180}
428 Instances of this class implement a parallel projection for the
429 given parameters. There is no distance for that transformation
430 (compared to the central projection). All other parameters are
431 identical to the \class{central} class.
432 \end{classdesc} % }}}
434 \section{Module \module{graph.data}: Data} % {{{
435 \label{graph:data}
437 \declaremodule{}{graph.data}
438 \modulesynopsis{Graph data}
440 The following classes provide data for the \method{plot()} method of a
441 graph. The classes are implemented in \module{graph.data}.
443 \begin{classdesc}{file}{filename, % {{{
444 commentpattern=defaultcommentpattern,
445 columnpattern=defaultcolumnpattern,
446 stringpattern=defaultstringpattern,
447 skiphead=0, skiptail=0, every=1, title=notitle,
448 context=\{\}, copy=1,
449 replacedollar=1, columncallback="\_\_column\_\_",
450 **columns}
451 This class reads data from a file and makes them available to the
452 graph system. \var{filename} is the name of the file to be read.
453 The data should be organized in columns.
455 The arguments \var{commentpattern}, \var{columnpattern}, and
456 \var{stringpattern} are responsible for identifying the data in each
457 line of the file. Lines matching \var{commentpattern} are ignored
458 except for the column name search of the last non-empty comment line
459 before the data. By default a line starting with one of the
460 characters \character{\#}, \character{\%}, or \character{!} as well
461 as an empty line is treated as a comment.
463 A non-comment line is analysed by repeatedly matching
464 \var{stringpattern} and, whenever the stringpattern does not match,
465 by \var{columnpattern}. When the \var{stringpattern} matches, the
466 result is taken as the value for the next column without further
467 transformations. When \var{columnpattern} matches, it is tried to
468 convert the result to a float. When this fails the result is taken
469 as a string as well. By default, you can write strings with spaces
470 surrounded by \character{\textquotedbl} immediately surrounded by
471 spaces or begin/end of line in the data file. Otherwise
472 \character{\textquotedbl} is not taken to be special.
474 \var{skiphead} and \var{skiptail} are numbers of data lines to be
475 ignored at the beginning and end of the file while \var{every}
476 selects only every \var{every} line from the data.
478 \var{title} is the title of the data to be used in the graph key. A
479 default title is constructed out of \var{filename} and
480 \var{**columns}. You may set \var{title} to \code{None} to disable
481 the title.
483 Finally, \var{columns} define columns out of the existing columns
484 from the file by a column number or a mathematical expression (see
485 below). When \var{copy} is set the names of the columns in the file
486 (file column names) and the freshly created columns having the names
487 of the dictionary key (data column names) are passed as data to the
488 graph styles. The data columns may hide file columns when names are
489 equal. For unset \var{copy} the file columns are not available to
490 the graph styles.
492 File column names occur when the data file contains a comment line
493 immediately in front of the data (except for empty or empty comment
494 lines). This line will be parsed skipping the matched comment
495 identifier as if the line would be regular data, but it will not be
496 converted to floats even if it would be possible to convert the
497 items. The result is taken as file column names, \emph{i.e.} a
498 string representation for the columns in the file.
500 The values of \var{**columns} can refer to column numbers in the
501 file starting at \code{1}. The column \code{0} is also available
502 and contains the line number starting from \code{1} not counting
503 comment lines, but lines skipped by \var{skiphead}, \var{skiptail},
504 and \var{every}. Furthermore values of \var{**columns} can be
505 strings: file column names or complex mathematical expressions. To
506 refer to columns within mathematical expressions you can also use
507 file column names when they are valid variable identifiers. Equal
508 named items in context will then be hidden. Alternatively columns
509 can be access by the syntax \code{\$\textless number\textgreater}
510 when \var{replacedollar} is set. They will be translated into
511 function calls to \var{columncallback}, which is a function to
512 access column data by index or name.
514 \var{context} allows for accessing external variables and functions
515 when evaluating mathematical expressions for columns. Additionally
516 to the identifiers in \var{context}, the file column names, the
517 \var{columncallback} function and the functions shown in the table
518 ``builtins in math expressions'' at the end of the section are
519 available.
521 Example:
522 \begin{verbatim}
523 graph.data.file("test.dat", a=1, b="B", c="2*B+$3")
524 \end{verbatim}
525 with \file{test.dat} looking like:
526 \begin{verbatim}
527 # A B C
528 1.234 1 2
529 5.678 3 4
530 \end{verbatim}
531 The columns with name \code{"a"}, \code{"b"}, \code{"c"} will become
532 \code{"[1.234, 5.678]"}, \code{"[1.0, 3.0]"}, and \code{"[4.0,
533 10.0]"}, respectively. The columns \code{"A"}, \code{"B"},
534 \code{"C"} will be available as well, since \var{copy} is enabled by
535 default.
537 When creating several data instances accessing the same file,
538 the file is read only once. There is an inherent caching of the
539 file contents.
540 \end{classdesc}
542 For the sake of completeness we list the default patterns:
544 \begin{memberdesc}{defaultcommentpattern}
545 \code{re.compile(r\textquotedbl (\#+|!+|\%+)\e s*\textquotedbl)}
546 \end{memberdesc}
548 \begin{memberdesc}{defaultcolumnpattern}
549 \code{re.compile(r\textquotedbl\e \textquotedbl(.*?)\e \textquotedbl(\e s+|\$)\textquotedbl)}
550 \end{memberdesc}
552 \begin{memberdesc}{defaultstringpattern}
553 \code{re.compile(r\textquotedbl(.*?)(\e s+|\$)\textquotedbl)}
554 \end{memberdesc} % }}}
556 \begin{classdesc}{function}{expression, title=notitle, % {{{
557 min=None, max=None, points=100,
558 context=\{\}}
559 This class creates graph data from a function. \var{expression} is
560 the mathematical expression of the function. It must also contain
561 the result variable name including the variable the function depends
562 on by assignment. A typical example looks like \code{"y(x)=sin(x)"}.
564 \var{title} is the title of the data to be used in the graph key. By
565 default \var{expression} is used. You may set \var{title} to
566 \code{None} to disable the title.
568 \var{min} and \var{max} give the range of the variable. If not set,
569 the range spans the whole axis range. The axis range might be set
570 explicitly or implicitly by ranges of other data. \var{points} is
571 the number of points for which the function is calculated. The
572 points are choosen linearly in terms of graph coordinates.
574 \var{context} allows for accessing external variables and functions.
575 Additionally to the identifiers in \var{context}, the variable name
576 and the functions shown in the table ``builtins in math
577 expressions'' at the end of the section are available.
578 \end{classdesc} % }}}
580 \begin{classdesc}{paramfunction}{varname, min, max, expression, % {{{
581 title=notitle, points=100,
582 context=\{\}}
583 This class creates graph data from a parametric function.
584 \var{varname} is the parameter of the function. \var{min} and
585 \var{max} give the range for that variable. \var{points} is the
586 number of points for which the function is calculated. The points
587 are choosen lineary in terms of the parameter.
589 \var{expression} is the mathematical expression for the parametric
590 function. It contains an assignment of a tuple of functions to a
591 tuple of variables. A typical example looks like
592 \code{"x, y = cos(k), sin(k)"}.
594 \var{title} is the title of the data to be used in the graph key. By
595 default \var{expression} is used. You may set \var{title} to
596 \code{None} to disable the title.
598 \var{context} allows for accessing external variables and functions.
599 Additionally to the identifiers in \var{context}, \var{varname} and
600 the functions shown in the table ``builtins in math expressions'' at
601 the end of the section are available.
602 \end{classdesc} % }}}
604 \begin{classdesc}{values}{title="user provided values", % {{{
605 **columns}
606 This class creates graph data from externally provided data.
607 Each column is a list of values to be used for that column.
609 \var{title} is the title of the data to be used in the graph key.
610 \end{classdesc} % }}}
612 \begin{classdesc}{points}{data, title="user provided points", % {{{
613 addlinenumbers=1, **columns}
614 This class creates graph data from externally provided data.
615 \var{data} is a list of lines, where each line is a list of data
616 values for the columns.
618 \var{title} is the title of the data to be used in the graph key.
620 The keywords of \var{**columns} become the data column names. The
621 values are the column numbers starting from one, when
622 \var{addlinenumbers} is turned on (the zeroth column is added to
623 contain a line number in that case), while the column numbers starts
624 from zero, when \var{addlinenumbers} is switched off.
625 \end{classdesc} % }}}
627 \begin{classdesc}{data}{data, title=notitle, context={}, copy=1, % {{{
628 replacedollar=1, columncallback="\_\_column\_\_", **columns}
629 This class provides graph data out of other graph data. \var{data}
630 is the source of the data. All other parameters work like the equally
631 called parameters in \class{graph.data.file}. Indeed, the latter is
632 built on top of this class by reading the file and caching its
633 contents in a \class{graph.data.list} instance.
634 \end{classdesc} % }}}
636 \begin{classdesc}{conffile}{filename, title=notitle, context={}, copy=1, % {{{
637 replacedollar=1, columncallback="\_\_column\_\_", **columns}
638 This class reads data from a config file with the file name
639 \var{filename}. The format of a config file is described within the
640 documentation of the \module{ConfigParser} module of the Python
641 Standard Library.
643 Each section of the config file becomes a data line. The options in
644 a section are the columns. The name of the options will be used as
645 file column names. All other parameters work as in
646 \var{graph.data.file} and \var{graph.data.data} since they all use
647 the same code.
648 \end{classdesc} % }}}
650 \begin{classdesc}{cbdfile}{filename, minrank=None, maxrank=None, % {{{
651 title=notitle, context={}, copy=1,
652 replacedollar=1, columncallback="\_\_column\_\_", **columns}
653 This is an experimental class to read map data from cbd-files. See
654 \url{http://sepwww.stanford.edu/ftp/World_Map/} for some world-map
655 data.
656 \end{classdesc} % }}}
658 The builtins in math expressions are listed in the following table:
659 \begin{tableii}{l|l}{textrm}{name}{value}
660 \code{neg}&\code{lambda x: -x}\\
661 \code{abs}&\code{lambda x: x < 0 and -x or x}\\
662 \code{sgn}&\code{lambda x: x < 0 and -1 or 1}\\
663 \code{sqrt}&\code{math.sqrt}\\
664 \code{exp}&\code{math.exp}\\
665 \code{log}&\code{math.log}\\
666 \code{sin}&\code{math.sin}\\
667 \code{cos}&\code{math.cos}\\
668 \code{tan}&\code{math.tan}\\
669 \code{asin}&\code{math.asin}\\
670 \code{acos}&\code{math.acos}\\
671 \code{atan}&\code{math.atan}\\
672 \code{sind}&\code{lambda x: math.sin(math.pi/180*x)}\\
673 \code{cosd}&\code{lambda x: math.cos(math.pi/180*x)}\\
674 \code{tand}&\code{lambda x: math.tan(math.pi/180*x)}\\
675 \code{asind}&\code{lambda x: 180/math.pi*math.asin(x)}\\
676 \code{acosd}&\code{lambda x: 180/math.pi*math.acos(x)}\\
677 \code{atand}&\code{lambda x: 180/math.pi*math.atan(x)}\\
678 \code{norm}&\code{lambda x, y: math.hypot(x, y)}\\
679 \code{splitatvalue}&see the \code{splitatvalue} description below\\
680 \code{pi}&\code{math.pi}\\
681 \code{e}&\code{math.e}
682 \end{tableii}
683 \code{math} refers to Pythons \module{math} module. The
684 \code{splitatvalue} function is defined as:
686 \begin{funcdesc}{splitatvalue}{value, *splitpoints}
687 This method returns a tuple \code{(section, \var{value})}.
688 The section is calculated by comparing \var{value} with the values
689 of {splitpoints}. If \var{splitpoints} contains only a single item,
690 \code{section} is \code{0} when value is lower or equal this item
691 and \code{1} else. For multiple splitpoints, \code{section} is
692 \code{0} when its lower or equal the first item, \code{None} when
693 its bigger than the first item but lower or equal the second item,
694 \code{1} when its even bigger the second item, but lower or equal
695 the third item. It continues to alter between \code{None} and
696 \code{2}, \code{3}, etc.
697 \end{funcdesc}
699 % }}}
701 \section{Module \module{graph.style}: Styles} % {{{
702 \label{graph:style}
704 \declaremodule{}{graph.style}
705 \modulesynopsis{Graph style}
707 Please note that we are talking about graph styles here. Those are
708 responsible for plotting symbols, lines, bars and whatever else into a
709 graph. Do not mix it up with path styles like the line width, the line
710 style (solid, dashed, dotted \emph{etc.}) and others.
712 The following classes provide styles to be used at the \method{plot()}
713 method of a graph. The plot method accepts a list of styles. By that
714 you can combine several styles at the very same time.
716 Some of the styles below are hidden styles. Those do not create any
717 output, but they perform internal data handling and thus help on
718 modularization of the styles. Usually, a visible style will depend on
719 data provided by one or more hidden styles but most of the time it is
720 not necessary to specify the hidden styles manually. The hidden styles
721 register themself to be the default for providing certain internal
722 data.
724 \begin{classdesc}{pos}{epsilon=1e-10} % {{{
725 This class is a hidden style providing a position in the graph. It
726 needs a data column for each graph dimension. For that the column
727 names need to be equal to an axis name. Data points are considered
728 to be out of graph when their position in graph coordinates exceeds
729 the range [0:1] by more than \var{epsilon}.
730 \end{classdesc} % }}}
732 \begin{classdesc}{range}{usenames={}, epsilon=1e-10} % {{{
733 This class is a hidden style providing an errorbar range. It needs
734 data column names constructed out of a axis name \code{X} for each
735 dimension errorbar data should be provided as follows:
736 \begin{tableii}{l|l}{}{data name}{description}
737 \lineii{\code{Xmin}}{minimal value}
738 \lineii{\code{Xmax}}{maximal value}
739 \lineii{\code{dX}}{minimal and maximal delta}
740 \lineii{\code{dXmin}}{minimal delta}
741 \lineii{\code{dXmax}}{maximal delta}
742 \end{tableii}
743 When delta data are provided the style will also read column data
744 for the axis name \code{X} itself. \var{usenames} allows to insert a
745 translation dictionary from axis names to the identifiers \code{X}.
747 \var{epsilon} is a comparison precision when checking for invalid
748 errorbar ranges.
749 \end{classdesc} % }}}
751 \begin{classdesc}{symbol}{symbol=changecross, size=0.2*unit.v\_cm, % {{{
752 symbolattrs=[]}
753 This class is a style for plotting symbols in a graph.
754 \var{symbol} refers to a (changeable) symbol function with the
755 prototype \code{symbol(c, x\_pt, y\_pt, size\_pt, attrs)} and draws
756 the symbol into the canvas \code{c} at the position \code{(x\_pt,
757 y\_pt)} with size \code{size\_pt} and attributes \code{attrs}. Some
758 predefined symbols are available in member variables listed below.
759 The symbol is drawn at size \var{size} using \var{symbolattrs}.
760 \var{symbolattrs} is merged with \code{defaultsymbolattrs} which is
761 a list containing the decorator \class{deco.stroked}. An instance of
762 \class{symbol} is the default style for all graph data classes
763 described in section~\ref{graph:data} except for \class{function}
764 and \class{paramfunction}.
765 \end{classdesc}
767 The class \class{symbol} provides some symbol functions as member
768 variables, namely:
770 \begin{memberdesc}{cross}
771 A cross. Should be used for stroking only.
772 \end{memberdesc}
774 \begin{memberdesc}{plus}
775 A plus. Should be used for stroking only.
776 \end{memberdesc}
778 \begin{memberdesc}{square}
779 A square. Might be stroked or filled or both.
780 \end{memberdesc}
782 \begin{memberdesc}{triangle}
783 A triangle. Might be stroked or filled or both.
784 \end{memberdesc}
786 \begin{memberdesc}{circle}
787 A circle. Might be stroked or filled or both.
788 \end{memberdesc}
790 \begin{memberdesc}{diamond}
791 A diamond. Might be stroked or filled or both.
792 \end{memberdesc}
794 \class{symbol} provides some changeable symbol functions as member
795 variables, namely:
797 \begin{memberdesc}{changecross}
798 attr.changelist([cross, plus, square, triangle, circle, diamond])
799 \end{memberdesc}
801 \begin{memberdesc}{changeplus}
802 attr.changelist([plus, square, triangle, circle, diamond, cross])
803 \end{memberdesc}
805 \begin{memberdesc}{changesquare}
806 attr.changelist([square, triangle, circle, diamond, cross, plus])
807 \end{memberdesc}
809 \begin{memberdesc}{changetriangle}
810 attr.changelist([triangle, circle, diamond, cross, plus, square])
811 \end{memberdesc}
813 \begin{memberdesc}{changecircle}
814 attr.changelist([circle, diamond, cross, plus, square, triangle])
815 \end{memberdesc}
817 \begin{memberdesc}{changediamond}
818 attr.changelist([diamond, cross, plus, square, triangle, circle])
819 \end{memberdesc}
821 \begin{memberdesc}{changesquaretwice}
822 attr.changelist([square, square, triangle, triangle, circle, circle, diamond, diamond])
823 \end{memberdesc}
825 \begin{memberdesc}{changetriangletwice}
826 attr.changelist([triangle, triangle, circle, circle, diamond, diamond, square, square])
827 \end{memberdesc}
829 \begin{memberdesc}{changecircletwice}
830 attr.changelist([circle, circle, diamond, diamond, square, square, triangle, triangle])
831 \end{memberdesc}
833 \begin{memberdesc}{changediamondtwice}
834 attr.changelist([diamond, diamond, square, square, triangle, triangle, circle, circle])
835 \end{memberdesc}
837 The class \class{symbol} provides two changeable decorators for
838 alternated filling and stroking. Those are especially useful in
839 combination with the \method{change}-\method{twice}-symbol methods
840 above. They are:
842 \begin{memberdesc}{changestrokedfilled}
843 attr.changelist([deco.stroked, deco.filled])
844 \end{memberdesc}
846 \begin{memberdesc}{changefilledstroked}
847 attr.changelist([deco.filled, deco.stroked])
848 \end{memberdesc} % }}}
850 \begin{classdesc}{line}{lineattrs=[]} % {{{
851 This class is a style to stroke lines in a graph.
852 \var{lineattrs} is merged with \code{defaultlineattrs} which is
853 a list containing the member variable \code{changelinestyle} as
854 described below. An instance of \class{line} is the default style
855 of the graph data classes \class{function} and \class{paramfunction}
856 described in section~\ref{graph:data}.
857 \end{classdesc}
859 The class \class{line} provides a changeable line style. Its
860 definition is:
862 \begin{memberdesc}{changelinestyle}
863 attr.changelist([style.linestyle.solid, style.linestyle.dashed, style.linestyle.dotted, style.linestyle.dashdotted])
864 \end{memberdesc} % }}}
866 \begin{classdesc}{impulses}{lineattrs=[], fromvalue=0, % {{{
867 frompathattrs=[], valueaxisindex=1}
868 This class is a style to plot impulses. \var{lineattrs} is merged
869 with \code{defaultlineattrs} which is a list containing the member
870 variable \code{changelinestyle} of the \class{line} class.
871 \var{fromvalue} is the baseline value of the impulses. When set to
872 \code{None}, the impulses will start at the baseline. When fromvalue
873 is set, \var{frompathattrs} are the stroke attributes used to show
874 the impulses baseline path.
875 \end{classdesc} % }}}
877 \begin{classdesc}{errorbar}{size=0.1*unit.v\_cm, errorbarattrs=[], % {{{
878 epsilon=1e-10}
879 This class is a style to stroke errorbars in a graph. \var{size} is
880 the size of the caps of the errorbars and \var{errorbarattrs} are
881 the stroke attributes. Errorbars and error caps are considered to be
882 out of the graph when their position in graph coordinates exceeds
883 the range [0:1] by more that \var{epsilon}. Out of graph caps are
884 omitted and the errorbars are cut to the valid graph range.
885 \end{classdesc} % }}}
887 \begin{classdesc}{text}{textname="text", dxname=None, dyname=None, % {{{
888 dxunit=0.3*unit.v\_cm, dyunit=0.3*unit.v\_cm,
889 textdx=0*unit.v\_cm, textdy=0.3*unit.v\_cm,
890 textattrs=[]}
891 This class is a style to stroke text in a graph. The
892 text to be written has to be provided in the data column named
893 \code{textname}. \var{textdx} and \var{textdy} are the position of the
894 text with respect to the position in the graph. Alternatively you can
895 specify a \code{dxname} and a \code{dyname} and provide appropriate
896 data in those columns to be taken in units of \var{dxunit} and
897 \var{dyunit} to specify the position of the text for each point
898 separately. \var{textattrs} are text attributes for the output of
899 the text. Those attributes are merged with the default attributes
900 \code{textmodule.halign.center} and \code{textmodule.vshift.mathaxis}.
901 \end{classdesc} % }}}
903 \begin{classdesc}{arrow}{linelength=0.25*unit.v\_cm, % {{{
904 arrowsize=0.15*unit.v\_cm,
905 lineattrs=[], arrowattrs=[], arrowpos=0.5,
906 epsilon=1e-10}
907 This class is a style to plot short lines with arrows into a
908 two-dimensional graph to a given graph position. The arrow
909 parameters are defined by two additional data columns named
910 \code{size} and \code{angle} define the size and angle for each
911 arrow. \code{size} is taken as a factor to \var{arrowsize} and
912 \var{linelength}, the size of the arrow and the length of the line
913 the arrow is plotted at. \code{angle} is the angle the arrow points
914 to with respect to a horizontal line. The \code{angle} is taken in
915 degrees and used in mathematically positive sense. \var{lineattrs}
916 and \var{arrowattrs} are styles for the arrow line and arrow head,
917 respectively. \var{arrowpos} defines the position of the arrow line
918 with respect to the position at the graph. The default \code{0.5}
919 means centered at the graph position, whereas \code{0} and \code{1}
920 creates the arrows to start or end at the graph position,
921 respectively. \var{epsilon} is used as a cutoff for short arrows in
922 order to prevent numerical instabilities.
923 \end{classdesc} % }}}
925 \begin{classdesc}{rect}{gradient=color.gradient.Grey} % {{{
926 This class is a style to plot colored rectangles into a
927 two-dimensional graph. The size of the rectangles is taken from
928 the data provided by the \class{range} style. The additional
929 data column named \code{color} specifies the color of the rectangle
930 defined by \var{gradient}. The valid color range is [0:1].
932 \begin{note}
933 Although this style can be used for plotting colored surfaces, it
934 will lead to a huge memory footprint of \PyX{} together with a
935 long running time and large outputs. Improved support for colored
936 surfaces is planned for the future.
937 \end{note}
938 \end{classdesc} % }}}
940 \begin{classdesc}{histogram}{lineattrs=[], steps=0, fromvalue=0, % {{{
941 frompathattrs=[], fillable=0, rectkey=0,
942 autohistogramaxisindex=0,
943 autohistogrampointpos=0.5, epsilon=1e-10}
944 This class is a style to plot histograms. \var{lineattrs} is merged
945 with \code{defaultlineattrs} which is \code{[deco.stroked]}. When
946 \var{steps} is set, the histrogram is plotted as steps instead of
947 the default being a boxed histogram. \var{fromvalue} is the baseline
948 value of the histogram. When set to \code{None}, the histogram will
949 start at the baseline. When fromvalue is set, \var{frompathattrs}
950 are the stroke attributes used to show the histogram baseline path.
952 The \var{fillable} flag changes the stoke line of the histogram to
953 make it fillable properly. This is important on non-steped
954 histograms or on histograms, which hit the graph boundary.
955 \var{rectkey} can be set to generate a rectanglar area instead of a
956 line in the graph key.
958 In the most general case, a histogram is defined by a range
959 specification (like for an errorbar) in one graph dimension (say,
960 along the x-axis) and a value for the other graph dimension. This
961 allows for the widths of the histogram boxes being variable. Often,
962 however, all histogram bin ranges are equally sized, and instead of
963 passing the range, the position of the bin along the x-axis fully
964 specifies the histogram - assuming that there are at least two bins.
965 This common case is supported via two parameters:
966 \var{autohistogramaxisindex}, which defines the index of the
967 independent histogram axis (in the case just described this would be
968 \code{0} designating the x axis). \var{autohistogrampointpos},
969 defines the relative position of the center of the histogram bin:
970 \code{0.5} means that the bin is centered at the values passed to
971 the style, \code{0} (\code{1}) means that the bin is aligned at the
972 right-(left-)hand side.
974 XXX describe, how to specify general histograms with varying bin widths
976 Positions of the histograms are considered to be out of graph when
977 they exceed the graph coordinate range [0:1] by more than
978 \var{epsilon}.
979 \end{classdesc} % }}}
981 \begin{classdesc}{barpos}{fromvalue=None, frompathattrs=[], epsilon=1e-10} % {{{
982 This class is a hidden style providing position information in a bar
983 graph. Those graphs need to contain a specialized axis, namely a bar
984 axis. The data column for this bar axis is named \code{Xname} where
985 \code{X} is an axis name. In the other graph dimension the data
986 column name must be equal to an axis name. To plot several bars in a
987 single graph side by side, you need to have a nested bar axis and
988 provide a tuple as data for nested bar axis.
990 The bars start at \var{fromvalue} when provided. The \var{fromvalue}
991 is marked by a gridline stroked using \var{frompathattrs}. Thus this
992 hidden style might actually create some output. The value of a bar
993 axis is considered to be out of graph when its position in graph
994 coordinates exceeds the range [0:1] by more than \var{epsilon}.
995 \end{classdesc} % }}}
997 \begin{classdesc}{stackedbarpos}{stackname, addontop=0, epsilon=1e-10} % {{{
998 This class is a hidden style providing position information in a bar
999 graph by stacking a new bar on top of another bar. The value of the
1000 new bar is taken from the data column named \var{stackname}. When
1001 \var{addontop} is set, the values is taken relative to the previous
1002 top of the bar.
1003 \end{classdesc} % }}}
1005 \begin{classdesc}{bar}{barattrs=[]} % {{{
1006 This class draws bars in a bar graph. The bars are filled using
1007 \var{barattrs}. \var{barattrs} is merged with \code{defaultbarattrs}
1008 which is a list containing \code{[color.gradient.Rainbow,
1009 deco.stroked([color.grey.black])]}.
1010 \end{classdesc} % }}}
1012 \begin{classdesc}{changebar}{barattrs=[]} % {{{
1013 This style works like the \class{bar} style, but instead of the
1014 \var{barattrs} to be changed on subsequent data instances the
1015 \var{barattrs} are changed for each value within a single data
1016 instance. In the result the style can't be applied to several data
1017 instances. The style raises an error instead.
1018 \end{classdesc} % }}}
1020 \begin{classdesc}{gridpos}{index1=0, index2=1, % {{{
1021 gridlines1=1, gridlines2=1, gridattrs=[],
1022 epsilon=1e-10}
1023 This class is a hidden style providing rectangular grid information
1024 out of graph positions for graph dimensions \var{index1} and
1025 \var{index2}. Data points are considered to be out of graph when
1026 their position in graph coordinates exceeds the range [0:1] by more
1027 than \var{epsilon}. Data points are merged to a single graph
1028 coordinate value when their difference in graph coordinates is below
1029 \var{epsilon}.
1030 \end{classdesc} % }}}
1032 \begin{classdesc}{grid}{gridlines1=1, gridlines2=1, gridattrs=[]} % {{{
1033 Strokes a rectangular grid in the first grid direction, when
1034 \var{gridlines1} is set and in the second grid direction, when
1035 \var{gridlines2} is set. \var{gridattrs} is merged with
1036 \code{defaultgridattrs} which is a list containing the member
1037 variable \code{changelinestyle} of the \class{line} class.
1038 \end{classdesc} % }}}
1040 \begin{classdesc}{surface}{colorname="color", % {{{
1041 gradient=color.gradient.Grey,
1042 mincolor=None, maxcolor=None,
1043 gridlines1=0.05, gridlines2=0.05,
1044 gridcolor=None,
1045 backcolor=color.gray.black}
1046 Draws a surface of a rectangular grid. Each rectangle is divided
1047 into 4 triangles.
1049 The grid can be colored using values provided by the data column
1050 named \var{columnname}. The values are rescaled to the range [0:1]
1051 using mincolor and maxcolor (which are taken from the minimal and
1052 maximal values, but larger bounds could be set).
1054 If no \var{columnname} column exists, the surface style falls back
1055 to a lightning coloring taking into account the angle between the
1056 view ray and the triangle and the distance between viewer and
1057 triangle. The precise conversion is defined in the
1058 \method{lightning} method.
1060 If a \var{gridcolor} is set, the rectangular grid is marked by small
1061 stripes of the relative (compared to each rectangle) size of
1062 \var{gridlines1} and \var{gridlines2} for the first and second grid
1063 direction, respectively.
1065 \var{backcolor} is used to fill triangles shown from the back. If
1066 \var{backcolor} is set to \code{None}, back sides are not drawn
1067 differently from the front sides.
1069 The surface is encoded using a single mesh. While this is quite
1070 space efficient, it has the following implications:
1071 \begin{itemize}
1072 \item All colors must use the same color space.
1073 \item HSB colors are not allowed, whereas Gray, RGB, and CMYK are
1074 allowed. You can convert HSB colors into a different color space
1075 before passing them to the surface.
1076 \item The grid itself is also constructed out of triangles. The
1077 grid is transformed along with the triangles thus looking quite
1078 different from a stroked grid (as done by the grid style).
1079 \item Occlusion is handled by proper painting order.
1080 \item Color changes are continuous (in the selected color
1081 space) for each triangle.
1082 \end{itemize}
1083 \end{classdesc} % }}}
1085 % }}}
1087 \section{Module \module{graph.key}: Keys} % {{{
1088 \label{graph:key}
1090 \declaremodule{}{graph.key}
1091 \modulesynopsis{Graph keys}
1093 The following class provides a key, whose instances can be passed to
1094 the constructor keyword argument \code{key} of a graph. The class is
1095 implemented in \module{graph.key}.
1097 \begin{classdesc}{key}{dist=0.2*unit.v\_cm,
1098 pos="tr", hpos=None, vpos=None,
1099 hinside=1, vinside=1,
1100 hdist=0.6*unit.v\_cm,
1101 vdist=0.4*unit.v\_cm,
1102 symbolwidth=0.5*unit.v\_cm,
1103 symbolheight=0.25*unit.v\_cm,
1104 symbolspace=0.2*unit.v\_cm,
1105 textattrs=[],
1106 columns=1, columndist=0.5*unit.v\_cm,
1107 border=0.3*unit.v\_cm, keyattrs=None}
1108 This class writes the title of the data in a plot together with a
1109 small illustration of the style. The style is responsible for its
1110 illustration.
1112 \var{dist} is a visual length and a distance between the key
1113 entries. \var{pos} is the position of the key with respect to the
1114 graph. Allowed values are combinations of \code{"t"} (top),
1115 \code{"m"} (middle) and \code{"b"} (bottom) with \code{"l"} (left),
1116 \code{"c"} (center) and \code{"r"} (right). Alternatively, you may
1117 use \var{hpos} and \var{vpos} to specify the relative position
1118 using the range [0:1]. \var{hdist} and \var{vdist} are the distances
1119 from the specified corner of the graph. \var{hinside} and
1120 \var{vinside} are numbers to be set to 0 or 1 to define whether the
1121 key should be placed horizontally and vertically inside of the graph
1122 or not.
1124 \var{symbolwidth} and \var{symbolheight} are passed to the style to
1125 control the size of the style illustration. \var{symbolspace} is the
1126 space between the illustration and the text. \var{textattrs} are
1127 attributes for the text creation. They are merged with
1128 \code{[text.vshift.mathaxis]}.
1130 \var{columns} is a number of columns of the graph key and
1131 \var{columndist} is the distance between those columns.
1133 When \var{keyattrs} is set to contain some draw attributes, the
1134 graph key is enlarged by \var{border} and the key area is drawn
1135 using \var{keyattrs}.
1136 \end{classdesc} % }}} % }}}
1138 % vim:fdm=marker