13.1 theme - Defining the default behaviour of PyChart

##
13.1 `theme` - Defining the default behaviour of PyChart

You can change PyChart's behavior by setting variables in the module `theme`. After setting values, you must call `theme.reinitialize()` to reflect the changes to other parts of PyChart. Notice that these variables are meaningful only before the first call to area.T.draw() (see Section 6).

    theme.scale_factor = 3
    theme.reinitialize()

The below are the list of variables in the `theme` module that you can modify.

`scale_factor`
  This variable defines the scaling factor. The default value is 1.0, meaning that one point in PyChart actually means one PostScript point. Setting this value to 3.0, for example, makes PyChart draw everything three times larger.

  See Also:

  See Section 4 for how the length and the coordinate system are defined in PyChart.

`output_format`
  This variable sets the encoding of the data produced by PyChart. The value of this variable must be one of the following strings.

  `ps`:
  `eps`:
    Encapsulated PostScript. This is the default.

  `pdf`:
    Adobe Page Description Format, or PDF.

  `pdf-uncompressed`:
    PDF without compression. This option should be used for a debugging purpose only.

  `png`:
    PNG graphics. You need to have ghostscript (`gs`) installed to use this option, because PyChart internally calls ghostscript to convert PostScript to PNG.

    See Also:

    http://www.ghostscript.com/
      See this web page for more information about Ghostscript.

  `svg`:
    Scalable vector graphics.

    See Also:

    http://www.w3.org/Graphics/SVG/
      See this web page for more information about SVG.

  `x11`:
    Interactive display on in X window. This format works on UNIX-based systems, but not on Windows. You need to have ghostscript installed to use this option.

  When this variable is not set (or is set to `None`), PyChart guesses the format from the file name (`theme.output_file`; see below). Failing that, PyChart will generate an encapsulated PostScript file.

`output_file`
  Sets the output file name. Without this option, PyChart sends code to the standard output. If you want to produce multiple charts from a single Python source file, use `canvas.init(file)` (see Section 21).

`use_color`
  The default value of this variable is `False`. If the value is `True`, PyChart colorizes some of the default objects. If the value is `False`, PyChart uses gray scale for the color of these objects. In particular:

  - The standard color list (`colors.standards`) will include all the colors listed in X's RGB file. So you can use something like "`color.slate_blue`"1. See Section 15 for more about colors.

  - The standard fill style list (`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. See Section 16 for more about fill styles.

  - The standard line style list (`line_style.standards`) will be colorized. See Section 14 for more about line styles.

`default_font_family`
  This variable sets the default font family used when drawing texts. The default is Helvetica. See Section 17.1.

`default_font_size`
  This variable sets the font size used when drawing texts. The default is 9 points. See Section 17.1.

`default_halign`
  Sets the default horizontal alignment of texts (Default value: `/h`). See Section 17.1.

`default_valign`
  Sets the default vertical alignment of texts (Default value: `/v`). See Section 17.1.

`default_angle`
  Default text-drawing angle (Default value: 0). See Section 17.1.

`default_line_height`
  Defines the separation between two text lines. See Section 17.1.

`default_line_width`
  Set the default line width, in points ( see Section 4). (Default value: 0.4) See Section 14.

`debug_level`
  This variable 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.

`bounding_box`
  This variable, if set, manually sets the bounding box of the chart(s) produced by PyChart. It is a four-tuple of numbers, i.e., (xmin, ymin, xmax, ymax). PyChart usually calculates the bounding box of a chart automatically. Thus, you set this variable only when you want to override the calculation by PyChart, or PyChart screws the calculation. The latter situation happens especially when you use really thick lines for drawing. See also `delta_bounding_box`, described next.

`delta_bounding_box`
  This variable, if set, adjusts the size of the bounding box of the chart(s). It is a four-tuple of numbers (xmin, ymin, xmax, ymax). Each of the number is added to the bounding box computed by PyChart.

  If both `bounding_box` and `delta_bounding_box` are set, then `delta_bounding_box` is ignored.

After changing any of the variables described so far, you must call the `reinitialize` function to reflect the change to the rest of PyChart:

`reinitialize`( | )

  This procedure must be called after setting variables in the `theme` module. This procedure propagates the new values of the theme variables to other modules that depend on their values.

#### Footnotes

...color.slate_blue"1
  In fact, you can use these color names in gray-scale mode as well. They will appear in some gray color though.