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. Below is an
example, which 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 to guess, PyChart will dump
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
scaling.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 these objects.
The default value of this attribute 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.
The options can also be set from the command line. To do this, the program
that imports Pychart must call theme.get_options
on
start up, because Pychart itself is just a library.
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 un-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". The below code shows an example.
from pychart import * args = theme.get_options() ar = area.T(...) ... |
You can change PyChart's behaviour by setting variables in the module
theme
directly. After setting values, you must call
theme.reinitialize()
to reflect the changes in 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 Redirecting output).
|
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.