1 \chapter{Axes
\label{axis
}}
3 Axes are a fundamental component of graphs although there might be use
4 cases outside of the graph system. Internally axes are constructed out
5 of components, which handle different tasks and axis need to fullfill:
9 Basically a container for axis data and the components. It
10 implements the conversion of a data value to a graph coordinate of
11 range
[0:
1]. It does also handle the proper usage of the components
12 in complicated tasks (
\emph{i.e.
} combine the partitioner, texter,
13 painter and rater to find the best partitioning).
15 Ticks are plotted along the axis. They might be labeled with text as
17 \term{partitioner, in the code the short form ``parter'' is used
}
18 Creates one or several choises of tick lists suitable to a certain
21 Creates labels for ticks when they are not set manually.
23 Responsible to paint the axis.
25 Calculate ratings, which can be used to select the best suitable
29 The names above map directly to modules, which are provided in the
30 directory
\file{graph/axis
}. Sometimes it might be conventient to
31 import the axis directory directly rather access them through the
32 graph. This would look like:
35 graph.axis.painter() # and the like
37 from pyx.graph import axis
38 axis.painter() # this is shorter ...
41 In most cases different implementations are available through
42 different classes, which can be combined in various ways. There are
43 various axis examples distributed with
\PyX{}, where you can see some
44 of the features of the axis with a few lines of code each. Hence we
45 can here directly step on to the reference of the available
50 \declaremodule{}{graph.axis.axis
}
53 The following classes are part of the module
\module{graph.axis.axis
}.
54 However, there is a shortcut to access those classes via
55 \code{graph.axis
} directly. Instances of the classes can be passed to
56 the
\var{**axes
} keyword arguments of a graph. Those instances should
59 \begin{classdesc
}{linear
}{min=None, max=None, reverse=
0, divisor=None, title=None,
60 parter=parter.autolinear(), manualticks=
[],
61 density=
1, maxworse=
2, rater=rater.linear(),
62 texter=texter.mixed(), painter=painter.plain()
}
63 This class provides a linear axis.
\var{min
} and
\var{max
} are the
64 axis range. When not set, they are adjusted automatically by the
65 data to be plotted in the graph. Note, that some data might want to
66 access the range of an axis (
\emph{e.g.
} the
\class{function
} class
67 when no range was provided there) or you need to specify a range
68 when using the axis without plugging it into a graph (
\emph{e.g.
}
69 when drawing a axis along a path).
71 \var{reverse
} can be set to indicate a reversed axis starting with
72 bigger values first. Alternatively you can fix the axis range by
73 \var{min
} and
\var{max
} accordingly. When divisor is set, it is
74 taken to divide all data range and position informations while
75 creating ticks. You can create ticks not taking into account a
76 factor by that.
\var{title
} is the title of the axis.
78 \var{parter
} is a partitioner instance, which creates suitable ticks
79 for the axis range. Those ticks are merged with manual given ticks
80 by
\var{manualticks
} before proceeding with rating, painting
81 \emph{etc.
} Manually placed ticks win against those created by the
82 partitioner. For automatic partitioners, which are able to calculate
83 several possible tick lists for a given axis range, the
84 \var{density
} is a (linear) factor to favour more or less ticks. It
85 should not be stressed to much (its likely, that the result would be
86 unappropriate or not at all valid in terms of rating label
87 distances). But within a range of say
0.5 to
2 (even bigger for
88 large graphs) it can help to get less or more ticks than the default
89 would lead to.
\var{maxworse
} is a the number of trials with more
90 and less ticks when a better rating was already found.
\var{rater
}
91 is a rater instance, which rates the ticks and the label distances
92 for being best suitable. It also takes into account
\var{density
}.
93 The rater is only needed, when the partitioner creates several tick
96 \var{texter
} is a texter instance. It creates labels for those
97 ticks, which claim to have a label, but do not have a label string
98 set already. Ticks created by partitioners typically receive their
99 label strings by texters. The
\var{painter
} is finally used to
100 construct the output. Note, that usually several output
101 constructions are needed, since the rater is also used to rate the
102 distances between the label for an optimum.
105 \begin{classdesc
}{lin
}{...
}
106 This class is an abbreviation of
\class{linear
} described above.
109 \begin{classdesc
}{logarithmic
}{min=None, max=None, reverse=
0, divisor=None, title=None,
110 parter=parter.autologarithmic(), manualticks=
[],
111 density=
1, maxworse=
2, rater=rater.logarithmic(),
112 texter=texter.mixed(), painter=painter.plain()
}
113 This class provides a logarithmic axis. All parameters work like
114 \class{linear
}. Only two parameters have a different default:
115 \var{parter
} and
\var{rater
}. Furthermore and most importantly, the
116 mapping between data and graph coordinates is logarithmic.
119 \begin{classdesc
}{log
}{...
}
120 This class is an abbreviation of
\class{logarithmic
} described above.
123 \begin{classdesc
}{linked
}{linkedaxis, painter=painter.linked()
}
124 This class provides an axis, which is linked to another axis
125 instance. This means, it shares all its properties with the axis it
126 is linked too except for the painter. Thus a linked axis is painted
129 A standard use case are the
\code{x2
} and
\code{y2
} axes in an
130 x-y-graph. Linked axes to the
\code{x
} and
\code{y
} axes are created
131 automatically when not disabled by setting those axes to
132 \code{None
}. By that, ticks are stroked at both sides of an
133 x-y-graph. However, linked axes can be used for in other cases as
134 well. You can link axes within a graph or between different graphs
135 as long as the orgininal axis is finished first (it must fix its
139 \begin{classdesc
}{split
}{subaxes, splitlist=
[0.5],
140 splitdist=
0.1, relsizesplitdist=
1,
141 title=None, painter=painter.split()
}
142 This class provides an axis, splitting the input values to its
143 subaxes depeding on the range of the subaxes. Thus the subaxes
144 need to have fixed range, up to the minimum of the first axis and
145 the maximum of the last axis.
\var{subaxes
} actually takes the list
146 of subaxes.
\var{splitlist
} defines the positions of the spliting
147 in graph coordinates. Thus the length of
\var{subaxes
} must be the
148 length of
\var{splitlist
} plus one. If an entry in
\var{splitlist
}
149 is
\code{None
}, the axes aside define the split position taking into
150 account the ratio of the axes ranges (meassured by an internal
151 \code{relsize
} attribute of each axis).
153 \var{splitdist
} is the space reserved for a splitting in graph
154 coordinates, when the corresponding entry in
\var{splitlist
} is not
155 \code{None
}.
\var{relsizesplitdist
} is the space reserved for the
156 splitting in terms, when the corresponding entry in
\var{splitlist
}
157 is
\code{None
} compared to the
\code{relsize
} of the axes aside.
159 \var{title
} is the title of the split axes and
\var{painter
} is a
160 specialized painter, which takes care of marking the axes breaks,
161 while the painting of the subaxes are performed by their painters
165 \begin{classdesc
}{linkedsplit
}{linkedaxis,
166 painter=painter.linkedsplit(),
167 subaxispainter=omitsubaxispainter
}
168 This class provides an axis, which is linked to an instance of
169 \class{split
}. The purpose of a linked axis is described in class
170 \class{linked
} above.
\var{painter
} replaces the painter from the
171 \var{linkedaxis
} instance.
173 While this class creates linked axes for the subaxes of
174 \var{linkedsplit
} as well, the question arises what painters to use
175 there. When
\var{subaxispainter
} is not set, no painter is given
176 explicitly leaving this decision to the subaxes themself. This will
177 lead to omitting all labels and the title. However, you can use a
178 changeable attribute of painters in
\var{subaxispainter
} to replace
182 \begin{classdesc
}{bar
}{subaxis=None, multisubaxis=None,
183 dist=
0.5, firstdist=None, lastdist=None,
184 title=None, painter=painter.bar()
}
185 This class provides an axis suitable for a bar style. It handles a
186 discrete set of values and maps them to distinct ranges in graph
187 coordinates. For that, the axis gets a list as data values. The
188 first entry is taken to be one of the discrete values valid on this
189 axis. All other parameters, lets call them others, are passed to a
190 subaxis. When others has only one entry, it is passed as a value,
191 otherwise as a list. The result of the conversion done by the
192 subaxis is mapped into the graph coordinate range for this discrete
193 value. When neigher
\var{subaxis
} nor
\var{multisubaxis
} is set,
194 others must be a single value in range
[0:
1]. This value is used for
195 the position at the subaxis without converion.
197 When
\var{subaxis
} is set, it is used for the conversion of others.
198 When
\var{multisubaxis
} is set, it must be an instance of
\var{bar
}
199 as well. It is than dublicated for each of the discrete values
200 allowed for the axis. By that, you can create nested bar axes with
201 a different discrete values for each discrete value of the axis. It
202 is not allowed to set both,
\var{subaxis
} and
\var{multisubaxis
}.
204 \var{dist
} is used as the spacing between the ranges for each
205 distinct value. It is measured in the same units as the subaxis
206 results, thus the default value of
\code{0.5} means halve the width
207 between the distinct values as the width for each distinct value.
208 \var{firstdist
} and
\var{lastdist
} are used before the first and
209 after the last value. When set to
\code{None
}, halve of
\var{dist
}
212 \var{title
} is the title of the split axes and
\var{painter
} is a
213 specialized painter for an bar axis. When
\var{multisubaxis
} is
214 used, their painters are called as well, otherwise they are not
218 \begin{funcdesc
}{pathaxis
}{path, axis, direction=
1}
219 This function returns a (specialized) canvas containing the axis
220 \var{axis
} painted along the path
\var{path
}.
\var{direction
}
221 defines the direction of the ticks. Allowed values are
\code{1}
222 (left) and
\code{-
1} (right).
227 \declaremodule{}{graph.axis.tick
}
228 \modulesynopsis{Axes ticks
}
230 The following classes are part of the module
\module{graph.axis.tick
}.
232 \begin{classdesc
}{rational
}{x, power=
1, floatprecision=
10}
233 This class implements a rational number with infinite precision. For
234 that it stores two integers, the enumerator
\code{enum
} and a
235 denomintor
\code{denom
}. Note that the implementation of rational
236 number arithmetics is not at all complete and designed for its
237 special use case of axis parititioning in
\PyX{} preventing any
240 \var{x
} is the value of the rational created by a conversion from
241 one of the following input values:
243 \item A float. It is converted to a rational with finite precision
244 determined by
\var{floatprecision
}.
245 \item A string, which is parsed to a rational number with full
246 precision. It is also allowed to provide a fraction like
248 \item A sequence of two integers. Those integers are taken as
249 enumerator and denominator of the rational.
250 \item An instance defining instance variables
\code{enum
} and
251 \code{denom
} like
\class{rational
} itself.
254 \var{power
} is an integer to calculate
\code{\var{x
}**
\var{power
}}.
255 This is usefull at certain places in partitioners.
258 \begin{classdesc
}{tick
}{x, ticklevel=
0, labellevel=
0, label=None,
259 labelattrs=
[], power=
1, floatprecision=
10}
260 This class implements ticks based on rational numbers. Instances of
261 this class can be passed to the
\code{manualticks
} parameter of a
264 The parameters
\var{x
},
\var{power
}, and
\var{floatprecision
} share
265 its meaning with
\class{rational
}.
267 A tick has a tick level (
\emph{i.e.
} markers at the axis path) and a
268 label lavel (
\emph{e.i.
} place text at the axis path),
269 \var{ticklevel
} and
\var{labellevel
}. These are non-negative
270 integers or
\var{None
}. A value of
\code{0} means a regular tick or
271 label,
\code{1} stands for a subtick or sublabel,
\code{2} for
272 subsubtick or subsublabel and so on.
\code{None
} means omitting the
273 tick or label.
\var{label
} is the text of the label. When not set,
274 it can be created automatically by a texter.
\var{labelattrs
} are
275 the attributes for the labels.
278 \section{Partitioners
}
280 \declaremodule{}{graph.axis.parter
}
281 \modulesynopsis{Axes partitioners
}
283 The following classes are part of the module
\module{graph.axis.parter
}.
284 Instances of the classes can be passed to the parter keyword argument
287 \begin{classdesc
}{linear
}{tickdist=None, labeldist=None,
288 extendtick=
0, extendlabel=None,
290 Instances of this class creates equally spaced tick lists. The
291 distances between the ticks, subticks, subsubticks
\emph{etc.
}
292 starting from a tick at zero are given as first, second, third
293 \emph{etc.
} item of the list
\var{ticklist
}. For a tick position,
294 the lowest level wins,
\emph{i.e.
} for
\code{[2,
1]} even numbers
295 will have ticks whereas subticks are placed at odd integer. The
296 items of
\var{ticklist
} might be strings, floats or tuples as
297 described for the
\var{pos
} parameter of class
\class{tick
}.
299 \var{labeldist
} works equally for placing labels. When
300 \var{labeldist
} is kept
\code{None
}, labels will be placed at each
301 tick position, but sublabels
\emph{etc.
} will not be used. This copy
302 behaviour is also available
\emph{vice versa
} and can be disabled by
305 \var{extendtick
} can be set to a tick level for including the next
306 tick of that level when the data exceed the range covered by the
307 ticks by more then
\var{epsilon
}.
\var{epsilon
} is taken relative
308 to the axis range.
\var{extendtick
} is disabled when set to
309 \code{None
} or for fixed range axes.
\var{extendlabel
} works similar
310 to
\var{extendtick
} but for labels.
313 \begin{classdesc
}{lin
}{...
}
314 This class is an abbreviation of
\class{linear
} described above.
317 \begin{classdesc
}{autolinear
}{variants=defaultvariants,
320 Instances of this class creates equally spaced tick lists, where the
321 distance between the ticks is adjusted to the range of the axis
322 automatically. Variants are a list of possible choices for
323 \var{tickdist
} of
\class{linear
}. Further variants are build out of
324 these by multiplying or dividing all the values by multiples of
325 \code{10}.
\var{variants
} should be ordered that way, that the
326 number of ticks for a given range will decrease, hence the distances
327 between the ticks should increase within the
\var{variants
} list.
328 \var{extendtick
} and
\var{epsilon
} have the same meaning as in
332 \begin{memberdesc
}{defaultvariants
}
333 \code{[[tick.rational((
1,
1)),
334 tick.rational((
1,
2))
],
[tick.rational((
2,
1)), tick.rational((
1,
335 1))
],
[tick.rational((
5,
2)), tick.rational((
5,
4))
],
336 [tick.rational((
5,
1)), tick.rational((
5,
2))
]]}
339 \begin{classdesc
}{autolin
}{...
}
340 This class is an abbreviation of
\class{autolinear
} described above.
343 \begin{classdesc
}{preexp
}{pres, exp
}
344 This is a storrage class defining positions of ticks on a
345 logarithmic scale. It contains a list
\var{pres
} of positions $p_i$
346 and
\var{exp
}, a multiplicator $m$. Valid tick positions are defined
347 by $p_im^n$ for any integer $n$.
350 \begin{classdesc
}{logarithmic
}{tickpos=None, labelpos=None,
351 extendtick=
0, extendlabel=None,
353 Instances of this class creates tick lists suitable to logarithmic
354 axes. The positions of the ticks, subticks, subsubticks
\emph{etc.
}
355 are defined by the first, second, third
\emph{etc.
} item of the list
356 \var{tickpos
}, which are all
\class{preexp
} instances.
358 \var{labelpos
} works equally for placing labels. When
\var{labelpos
}
359 is kept
\code{None
}, labels will be placed at each tick position,
360 but sublabels
\emph{etc.
} will not be used. This copy behaviour is
361 also available
\emph{vice versa
} and can be disabled by an empty
364 \var{extendtick
},
\var{extendlabel
} and
\var{epsilon
} have the same
365 meaning as in
\class{linear
}.
368 Some
\class{preexp
} instances for the use in
\class{logarithmic
} are
369 available as instance variables (should be used read-only):
371 \begin{memberdesc
}{pre1exp5
}
372 \code{preexp(
[tick.rational((
1,
1))
],
100000)
}
375 \begin{memberdesc
}{pre1exp4
}
376 \code{preexp(
[tick.rational((
1,
1))
],
10000)
}
379 \begin{memberdesc
}{pre1exp3
}
380 \code{preexp(
[tick.rational((
1,
1))
],
1000)
}
383 \begin{memberdesc
}{pre1exp2
}
384 \code{preexp(
[tick.rational((
1,
1))
],
100)
}
387 \begin{memberdesc
}{pre1exp
}
388 \code{preexp(
[tick.rational((
1,
1))
],
10)
}
391 \begin{memberdesc
}{pre125exp
}
392 \code{preexp(
[tick.rational((
1,
1)), tick.rational((
2,
1)), tick.rational((
5,
1))
],
10)
}
395 \begin{memberdesc
}{pre1to9exp
}
396 \code{preexp(
[tick.rational((
1,
1)) for x in range(
1,
10)
],
10)
}
399 \begin{classdesc
}{log
}{...
}
400 This class is an abbreviation of
\class{logarithmic
} described above.
403 \begin{classdesc
}{autologarithmic
}{variants=defaultvariants,
404 extendtick=
0, extendlabel=None,
406 Instances of this class creates tick lists suitable to logarithmic
407 axes, where the distance between the ticks is adjusted to the range
408 of the axis automatically. Variants are a list of tuples with
409 possible choices for
\var{tickpos
} and
\var{labelpos
} of
410 \class{logarithmic
}.
\var{variants
} should be ordered that way, that
411 the number of ticks for a given range will decrease within the
414 \var{extendtick
},
\var{extendlabel
} and
\var{epsilon
} have the same
415 meaning as in
\class{linear
}.
418 \begin{memberdesc
}{defaultvariants
}
419 \code{[(
[log.pre1exp, log.pre1to9exp
],
[log.pre1exp,
420 log.pre125exp
]), (
[log.pre1exp, log.pre1to9exp
], None),
421 (
[log.pre1exp2, log.pre1exp
], None), (
[log.pre1exp3,
422 log.pre1exp
], None), (
[log.pre1exp4, log.pre1exp
], None),
423 (
[log.pre1exp5, log.pre1exp
], None)
]}
426 \begin{classdesc
}{autolog
}{...
}
427 This class is an abbreviation of
\class{autologarithmic
} described above.
432 \declaremodule{}{graph.axis.texter
}
433 \modulesynopsis{Axes texters
}
435 The following classes are part of the module
\module{graph.axis.texter
}.
436 Instances of the classes can be passed to the texter keyword argument
437 of regular axes. Texters are used to define the label text for ticks,
438 which request to have a label, but not label text was specified
439 actually. A typical case are ticks created by partitioners described
442 \begin{classdesc
}{decimal
}{prefix="", infix="", suffix="", equalprecision=
0,
443 decimalsep=".", thousandsep="", thousandthpartsep="",
444 plus="", minus="-", period=r"
\textbackslash overline\
{\%s\
}",
445 labelattrs=
[text.mathmode
]}
446 Instances of this class create decimal formatted labels.
448 The strings
\var{prefix
},
\var{infix
}, and
\var{suffix
} are added to
449 the label at the begin, immediately after the plus or minus, and at
450 the end, respectively.
\var{decimalsep
},
\var{thousandsep
}, and
451 \var{thousandthpartsep
} are strings used to separate integer from
452 fractional part and three-digit groups in the integer and fractional
453 part. The strings
\var{plus
} and
\var{minus
} are inserted in front
454 of the unsigned value for non-negative and negative numbers,
457 The format string
\var{period
} should generate a period. It must
458 contain one string insert operators
\samp{\%s
} for the period.
460 \var{labelattrs
} is a list of attributes to be added to the label
461 attributes given in the painter. It should be used to setup TeX
462 features like
\code{text.mathmode
}. Text format options like
463 \code{text.size
} should instead be set at the painter.
466 \begin{classdesc
}{exponential
}{plus="", minus="-",
467 mantissaexp=r"\
{\
{\%s\
}\textbackslash cdot10
\textasciicircum\
{\%s\
}\
}",
470 nomantissaexp=r"\
{10\textasciicircum\
{\%s\
}\
}",
471 minusnomantissaexp=r"\
{-
10\textasciicircum\
{\%s\
}\
}",
472 mantissamin=tick.rational((
1,
1)), mantissamax=tick.rational((
10L,
1)),
473 skipmantissa1=
0, skipallmantissa1=
1,
474 mantissatexter=decimal()
}
475 Instances of this class create decimal formatted labels with an
478 The strings
\var{plus
} and
\var{minus
} are inserted in front of the
479 unsigned value of the exponent.
481 The format string
\var{mantissaexp
} should generate the exponent. It
482 must contain two string insert operators
\samp{\%s
}, the first for
483 the mantissa and the second for the exponent. An alternative to the
484 default is
\samp{r
\textquotedbl\
{\
{\%s\
}\
{\e rm e\
}\
{\%s\
}\
}\textquotedbl}.
486 The format string
\var{skipexp0
} is used to skip exponent
\code{0} and must
487 contain one string insert operator
\samp{\%s
} for the mantissa.
488 \code{None
} turns off the special handling of exponent
\code{0}.
489 The format string
\var{skipexp1
} is similar to
\var{skipexp0
}, but
490 for exponent
\code{1}.
492 The format string
\var{nomantissaexp
} is used to skip the mantissa
493 \code{1} and must contain one string insert operator
\samp{\%s
} for
494 the exponent.
\code{None
} turns off the special handling of mantissa
495 \code{1}. The format string
\var{minusnomantissaexp
} is similar
496 to
\var{nomantissaexp
}, but for mantissa
\code{-
1}.
498 The
\class{tick.rational
} instances
\var{mantissamin
}\textless
499 \var{mantissamax
} are minimum (including) and maximum (excluding) of
502 The boolean
\var{skipmantissa1
} enables the skipping of any mantissa
503 equals
\code{1} and
\code{-
1}, when
\var{minusnomantissaexp
} is set.
504 When the boolean
\var{skipallmantissa1
} is set, a mantissa equals
505 \code{1} is skipped only, when all mantissa values are
\code{1}.
506 Skipping of a mantissa is stronger than the skipping of an exponent.
508 \var{mantissatexter
} is a texter instance for the mantissa.
511 \begin{classdesc
}{mixed
}{smallestdecimal=tick.rational((
1,
1000)),
512 biggestdecimal=tick.rational((
9999,
1)),
515 exponential=exponential()
}
516 Instances of this class create decimal formatted labels with an
517 exponential, when the unsigned values are small or large compared to
520 The rational instances
\var{smallestdecimal
} and
521 \var{biggestdecimal
} are the smallest and biggest decimal values,
522 where the decimal texter should be used. The sign of the value is
523 ignored here. For a tick at zero the decimal texter is considered
524 best as well.
\var{equaldecision
} is a boolean to indicate whether
525 the decision for the decimal or exponential texter should be done
526 globally for all ticks.
528 \var{decimal
} and
\var{exponential
} are a decimal and an exponential
529 texter instance, respectively.
532 \begin{classdesc
}{rational
}{prefix="", infix="", suffix="",
533 enumprefix="", enuminfix="", enumsuffix="",
534 denomprefix="", denominfix="", denomsuffix="",
535 plus="", minus="-", minuspos=
0, over=r"
{{\%s
}\textbackslash over
{\%s
}}",
536 equaldenom=
0, skip1=
1, skipenum0=
1, skipenum1=
1, skipdenom1=
1,
537 labelattrs=
[text.mathmode
]}
538 Instances of this class create labels formated as fractions.
540 The strings
\var{prefix
},
\var{infix
}, and
\var{suffix
} are added to
541 the label at the begin, immediately after the plus or minus, and at
542 the end, respectively. The strings
\var{prefixenum
},
543 \var{infixenum
}, and
\var{suffixenum
} are added to the labels
544 enumerator accordingly whereas
\var{prefixdenom
},
\var{infixdenom
},
545 and
\var{suffixdenom
} do the same for the denominator.
547 The strings
\var{plus
} and
\var{minus
} are inserted in front of the
548 unsigned value. The position of the sign is defined by
549 \var{minuspos
} with values
\code{1} (at the enumerator),
\code{0}
550 (in front of the fraction), and
\code{-
1} (at the denomerator).
552 The format string
\var{over
} should generate the fraction. It
553 must contain two string insert operators
\samp{\%s
}, the first for
554 the enumerator and the second for the denominator. An alternative to
555 the default is
\samp{\textquotedbl\
{\
{\%s\
}/\
{\%s\
}\
}\textquotedbl}.
557 Usually, the enumerator and denominator are canceled, while, when
558 \var{equaldenom
} is set, the least common multiple of all
559 denominators is used.
561 The boolean
\var{skip1
} indicates, that only the prefix, plus or minus,
562 the infix and the suffix should be printed, when the value is
563 \code{1} or
\code{-
1} and at least one of
\var{prefix
},
\var{infix
}
564 and
\var{suffix
} is present.
566 The boolean
\var{skipenum0
} indicates, that only a
\code{0} is
567 printed when the enumerator is zero.
569 \var{skipenum1
} is like
\var{skip1
} but for the enumerator.
571 \var{skipdenom1
} skips the denominator, when it is
\code{1} taking
572 into account
\var{denomprefix
},
\var{denominfix
},
\var{denomsuffix
}
573 \var{minuspos
} and the sign of the number.
575 \var{labelattrs
} has the same meaning than for
\var{decimal
}.
580 \declaremodule{}{graph.axis.painter
}
581 \modulesynopsis{Axes painters
}
583 The following classes are part of the module
584 \module{graph.axis.painter
}. Instances of the painter classes can be
585 passed to the painter keyword argument of regular axes.
587 \begin{classdesc
}{rotatetext
}{direction, epsilon=
1e-10}
588 This helper class is used in direction arguments of the painters
589 below to prevent axis labels and titles being written upside down.
590 In those cases the text will be rotated by
180 degrees.
591 \var{direction
} is an angle to be used relative to the tick
592 direction.
\var{epsilon
} is the value by which
90 degrees can be
593 exceeded before an
180 degree rotation is performed.
596 The following two class variables are initialized with the most common
599 \begin{memberdesc
}{parallel
}
600 \code{rotatetext(
90)
}
603 \begin{memberdesc
}{orthogonal
}
604 \code{rotatetext(
180)
}
607 \begin{classdesc
}{ticklength
}{initial, factor
}
608 This helper class provides changeable
\PyX{} lengths starting from
609 an initial value
\var{initial
} multiplied by
\var{factor
} again and
610 again. The resulting lengths are thus a geometric series.
613 There are some class variables initialized with suitable values for
614 tick stroking. They are named
\code{ticklength.SHORT
},
615 \code{ticklength.SHORt
},
\dots,
\code{ticklength.short
},
616 \code{ticklength.normal
},
\code{ticklength.long
},
\dots,
617 \code{ticklength.LONG
}.
\code{ticklength.normal
} is initialized with
618 a length of
\code{0.12} and the reciprocal of the golden mean as
619 \code{factor
} whereas the others have a modified inital value by
620 multiplication or division by multiples of $
\sqrt{2}$ appropriately.
622 \begin{classdesc
}{regular
}{innerticklength=ticklength.normal,
623 outerticklength=None,
634 titledirection=rotatetext.parallel,
636 texrunner=text.defaulttexrunner
}
637 Instances of this class are painters for regular axes like linear
638 and logarithmic axes.
640 \var{innerticklength
} and
\var{outerticklength
} are visual
\PyX{}
641 lengths of the ticks, subticks, subsubticks
\emph{etc.
} plotted
642 along the axis inside and outside of the graph. Provide changeable
643 attributes to modify the lengths of ticks compared to subticks
644 \emph{etc.
} \code{None
} turns off the ticks inside and outside the
647 \var{tickattrs
} and
\var{gridattrs
} are changeable stroke attributes
648 for the ticks and the grid, where
\code{None
} turns off the feature.
649 \var{basepathattrs
} are stroke attributes for the axis or
650 \code{None
} to turn it off.
\var{basepathattrs
} is merged with
651 \samp{[style.linecap.square
]}.
653 \var{labeldist
} is the distance of the labels from the axis base path
654 as a visual
\PyX{} length.
\var{labelattrs
} is a list of text
655 attributes for the labels. It is merged with
656 \samp{[text.halign.center, text.vshift.mathaxis
]}.
657 \var{labeldirection
} is an instance of
\var{rotatetext
} to rotate
658 the labels relative to the axis tick direction or
\code{None
}.
660 The boolean values
\var{labelhequalize
} and
\var{labelvequalize
}
661 force an equal alignment of all labels for straight vertical and
662 horizontal axes, respectively.
664 \var{titledist
} is the distance of the title from the rest of the
665 axis as a visual
\PyX{}.
\var{titleattrs
} is a list of text
666 attributes for the title. It is merged with
667 \samp{[text.halign.center, text.vshift.mathaxis
]}.
668 \var{titledirection
} is an instance of
\var{rotatetext
} to rotate
669 the title relative to the axis tick direction or
\code{None
}.
670 \var{titlepos
} is the position of the title in graph coordinates.
672 \var{texrunner
} is the texrunner instance to create axis text like
673 the axis title or labels.
676 \begin{classdesc
}{linked
}{innerticklength=ticklength.short,
677 outerticklength=None,
688 titledirection=rotatetext.parallel,
690 texrunner=text.defaulttexrunner
}
691 This class is identical to
\class{plain
} up to the default values of
692 \var{labelattrs
} and
\var{titleattrs
}. By turning off those
693 features, this painter is suitable for linked axes.
696 \begin{classdesc
}{split
}{breaklinesdist="
0.05 cm",
697 breaklineslength="
0.5 cm",
701 titledirection=rotatetext.parallel,
703 texrunner=text.defaulttexrunner
}
704 Instances of this class are suitable painters for split axes.
706 \var{breaklinesdist
} and
\var{breaklineslength
} are the distance
707 between axes break markers in visual
\PyX{} lengths.
708 \var{breaklinesangle
} is the angle of the axis break marker with
709 respect to the base path of the axis. All other parameters have the
710 same meaning as in
\class{plain
}.
713 \begin{classdesc
}{linkedsplit
}{breaklinesdist="
0.05 cm",
714 breaklineslength="
0.5 cm",
718 titledirection=rotatetext.parallel,
720 texrunner=text.defaulttexrunner
}
721 This class is identical to
\class{split
} up to the default value of
722 \var{titleattrs
}. By turning off this feature, this painter is
723 suitable for linked split axes.
726 \begin{classdesc
}{bar
}{innerticklength=None,
727 outerticklength=None,
738 titledirection=rotatetext.parallel,
740 texrunner=text.defaulttexrunner
}
741 Instances of this class are suitable painters for bar axes.
743 \var{innerticklength
} and
\var{outerticklength
} are visual
\PyX{}
744 length to mark the different bar regions along the axis inside and
745 outside of the graph.
\code{None
} turns off the ticks inside and
746 outside the graph, respectively.
\var{tickattrs
} are stroke
747 attributes for the ticks or
\code{None
} to turns all ticks off.
749 The parameters with prefix
\var{name
} are identical to their
750 \var{label
} counterparts in
\class{plain
}. All other parameters have
751 the same meaning as in
\class{plain
}.
754 \begin{classdesc
}{linkedbar
}{innerticklength=None,
755 outerticklength=None,
766 titledirection=rotatetext.parallel,
768 texrunner=text.defaulttexrunner
}
769 This class is identical to
\class{bar
} up to the default values of
770 \var{nameattrs
} and
\var{titleattrs
}. By turning off those features,
771 this painter is suitable for linked bar axes.
776 \declaremodule{}{graph.axis.rater
}
777 \modulesynopsis{Axes raters
}
779 The rating of axes is implemented in
\module{graph.axis.rater
}. When
780 an axis partitioning scheme returns several partitioning
781 possibilities, the partitions needs to be rated by a positive number.
782 The lowest rated axis partitioning is considered best.
784 The rating consists of two steps. The first takes into account only
785 the number of ticks, subticks, labels and so on in comparison to
786 optimal numbers. Additionally, the extension of the axis range by
787 ticks and labels is taken into account. This rating leads to a
788 preselection of possible partitions. In the second step, after the
789 layout of prefered partitionings is calculated, the distance of the
790 labels in a partition is taken into account as well at a smaller
791 weight factor by default. Thereby partitions with overlapping labels
792 will be rejected completely. Exceptionally sparse or dense labels will
793 receive a bad rating as well.
795 \begin{classdesc
}{cube
}{opt, left=None, right=None, weight=
1}
796 Instances of this class provide a number rater.
\var{opt
} is the
797 optimal value. When not provided,
\var{left
} is set to
\code{0} and
798 \var{right
} is set to
\code{3*
\var{opt
}}. Weight is a multiplicator
802 \code{\var{widht
}*((x-
\var{opt
})/(other-
\var{opt
}))**
3} to rate the
803 value
\code{x
}, where
\code{other
} is
\var{left
}
804 (
\code{x
}\textless\var{opt
}) or
\var{right
}
805 (
\code{x
}\textgreater\var{opt
}).
808 \begin{classdesc
}{distance
}{opt, weight=
0.1}
809 Instances of this class provide a rater for a list of numbers.
810 The purpose is to rate the distance between label boxes.
\var{opt
}
811 is the optimal value.
813 The rater calculates the sum of
\code{\var{weight
}*(
\var{opt
}/x-
1)
}
814 (
\code{x
}\textless\var{opt
}) or
\code{\var{weight
}*(x/
\var{opt
}-
1)
}
815 (
\code{x
}\textgreater\var{opt
}) for all elements
\code{x
} of the
816 list. It returns this value divided by the number of elements in the
820 \begin{classdesc
}{rater
}{ticks, labels, range, distance
}
821 Instances of this class are raters for axes partitionings.
823 \var{ticks
} and
\var{labels
} are both lists of number rater
824 instances, where the first items are used for the number of ticks
825 and labels, the second items are used for the number of subticks
826 (including the ticks) and sublabels (including the labels) and so on
827 until the end of the list is reached or no corresponding ticks are
830 \var{range
} is a number rater instance which rates the range of the
831 ticks relative to the range of the data.
833 \var{distance
} is an distance rater instance.
836 \begin{classdesc
}{linear
}{ticks=
[cube(
4), cube(
10, weight=
0.5)
],
838 range=cube(
1, weight=
2),
839 distance=distance("
1 cm")
}
840 This class is suitable to rate partitionings of linear axes. It is
841 equal to
\class{rater
} but defines predefined values for the
845 \begin{classdesc
}{lin
}{...
}
846 This class is an abbreviation of
\class{linear
} described above.
849 \begin{classdesc
}{logarithmic
}{ticks=
[cube(
5, right=
20), cube(
20, right=
100, weight=
0.5)
],
850 labels=
[cube(
5, right=
20), cube(
5, right=
20, weight=
0.5)
],
851 range=cube(
1, weight=
2),
852 distance=distance("
1 cm")
}
853 This class is suitable to rate partitionings of logarithmic axes. It
854 is equal to
\class{rater
} but defines predefined values for the
858 \begin{classdesc
}{log
}{...
}
859 This class is an abbreviation of
\class{logarithmic
} described above.