~ubuntu-branches/debian/sid/pyx/sid

« back to all changes in this revision

Viewing changes to examples/graphs/axis.txt

  • Committer: Bazaar Package Importer
  • Author(s): Stuart Prescott
  • Date: 2011-05-20 00:13:52 UTC
  • mto: (9.1.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 8.
  • Revision ID: james.westby@ubuntu.com-20110520001352-odcuqpdezuusbbw1
Tags: upstream-0.11.1
ImportĀ upstreamĀ versionĀ 0.11.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Using a logarithmic axis and defining the axis range and its label
 
2
 
 
3
Sometimes, you have to visualize rather pathological funtions containing
 
4
divergencies and/or varying over a large parameter range. This is best done
 
5
using an appropriate axis. Here, we show a simple example how to do
 
6
this with PyX. ...
 
7
 
 
8
In order to change the properties of the graph axes, we have to create
 
9
appropriate instances of an axis class and pass them as keyword arguments to
 
10
the `graph.graphxy` constructor. A number of predefined axes is contained in
 
11
the `graph.axis` module. Here, we use a linear (abbreviated as
 
12
`graph.axis.lin`) and a logarithmic (abbreviated as `graph.axis.log`) axis. In
 
13
both cases, we pass a minimal and maximal value for the axis range. Whereas for
 
14
the x-axis this is not strictly necessary (we could as well tell the
 
15
`graph.data.function` instance to emit data in a certain x-range), it is
 
16
important for the y-axis because the function diverges for certain x values. If
 
17
we do not set the y range manually, we would obtain a rather compressed display
 
18
of the function in the y-direction, which, moreover, would strongly depend on
 
19
the sampling points choosen by PyX along the x-direction. Since the function only
 
20
diverges towards positive y-values, we only need to set the maximal value of
 
21
the y-axis (using the `max`-argument). Of course, you can also fix the lower end
 
22
of the axis range by providing a `min`-argument. In order to introduce the
 
23
`title` keyword, we give names to the axes.
 
24
 
 
25
! Note how PyX changes the way the x-axis is drawn. Instead of simple decimal
 
26
numbers, an exponential notation is used. This happens automatically by
 
27
default, if at least one of the values to be shown becomes 10,000 or bigger
 
28
smaller than 0.001. This behaviour can be altered by using a different axis
 
29
texter.