Node:Options, Next:Anatomy, Previous:Introduction, Up:Top
The behavior of PyChart can be changed in three ways, via environment
variable PYCHART_OPTIONS
, via command-line options, and by
setting variables in module theme
directly.
The value of the environment variable PYCHART_OPTIONS
, if any,
should be a sequence of var=val
, separated by space. The below
example tells PyChart to write to file foo.pdf
and use
Times-Roman as the default font.
% PYCHART_OPTIONS="output=foo.pdf font-family=Times" % export PYCHART_OPTIONS
The summary of attributes that can be set via PYCHART_OPTIONS
follows.
output=filename
format=format
This option sets the encoding of the data produced by PyChart. Format must be one of the following:
ps
pdf
pdf-uncompressed
png
gs
) installed to use
this option, because PyChart internally calls ghostscript to convert ps
to png.
svg
x11
Without this option, PyChart guesses the format from the file name
(output=
filename). Failing that, PyChart will generate
encapsulated Postscript.
font-family=name
font-size=size
This option sets the default font family and size of texts. The default
is Helvetica at 9 points.
See font.
line-width=x
scale=n
theme.scale_factor
). The default
value is 1.0. See Unit.
color=[yes|no]
If yes, PyChart colorizes default object attributes. In particular:
colors.standards
) will include all
the colors listed in X's RGB file. So you can use something like
"color.slate_blue
"1
fill_style.standards
) will
be colorized. Thus, if you create a bar plot without explicitly
specifying its fill style, you will see colored bars on the canvas.
line_style.standards
) will be colorized.
If the value is no
, PyChart uses gray scale for the color of
these objects.
The default value of this option is no
.
debug-level=N
This option controls the verbosity of messages from PyChart. The
default value is 1, meaning that PyChart only displays error
messages. The larger the value, the more verbose PyChart becomes.
bbox=LEFT,BOTTOM,RIGHT,TOP
The value of this option is a sequence of four values, separated by
commas. Each value is of the form, +
num, -
num,
or num. +
num and -
num adds to or subtracts
from the bounding-box value computed by PyChart (the unit is Postscript
points; See Unit.) num sets the bounding box at that value. For
example,
bbox=-10,0,+10,100
Extends the bounding box 10 points to both left and right, and sets the vertical stretch from 0 to 100.
The options can also be set from the command line. To do this, the program
that imports Pychart must call theme.get_options
in the
beginning, because Pychart itself is just a library. Below is an example.
theme.get_options ARGV = sys.argv[1:] | Function |
This procedure takes a list of command line arguments in ARGV and parses
options. It returns the non-parsed portion of ARGV. ARGV can be
omitted, in which case its value defaults to sys.argv[1:] .
The options supported are: "--format=[ps|png|pdf|x11] ",
"--output= FILE", "--color=[yes|no] "
"--scale= X", "--font-family= NAME", "--font-size= X",
"--line-width= X",
"--debug-level= N", "bbox= LEFT,BOTTOM,RIGHT,TOP".
The below code shows an example.
#!/usr/bin/python from pychart import * args = theme.get_options() ar = area.T(...) ... |
You can change PyChart's behavior by setting variables in the module
theme
directly. After setting values, you must call
theme.reinitialize()
to reflect the changes to other parts of
PyChart.
theme.scale_factor = 3 theme.reinitialize()
The above example has the same effect as setting
"PYCHART_OPTIONS="scale=3"
".
theme.use_color | Variable |
Setting this variable to 1 has the same effect as
setting color=yes in PYCHART_OPTIONS.
|
theme.output_format | Variable |
Equivalent to format= in PYCHART_OPTIONS.
This option is meaningful only before calling area.draw()
(see area).
|
theme.output_file | Variable |
Equivalent to output= in PYCHART_OPTIONS.
This option is meaningful only before calling area.draw()
(see area).
If you want to produce multiple charts from a single Python source file,
use canvas.init(FILE) . See canvas.
|
theme.default_font_family | Variable |
Equivalent to font-family= in PYCHART_OPTIONS.
|
theme.default_font_size | Variable |
Equivalent to font-size= in PYCHART_OPTIONS.
|
theme.default_line_height | Variable |
Equivalent to line-height= in PYCHART_OPTIONS.
|
In fact, you can use these color names in gray-scale mode as well. They will appear in some gray color though.