PyChart Reference Manual

Node:Redirecting output, Previous:Clipping, Up:Tricks

### Redirecting output

You can write to multiple files by calling `canvas.init()` before calling Area's `draw()` method.

canvas.init FNAME | Function

Open a new canvas. Close the existing canvas, if any. Parameter "fname" specifies the file to which the contents of the canvas will be dumped when it closes. The format of the file is determined by variable "theme.output_format", or if it's None, by "fname"'s suffix - i.e., PDF if the file name ends with ".pdf", PNG if the file name ends with ".png", and Encapsulated PS otherwise.

For example, the below example draws the first chart to `foo.pdf` and the next chart to `bar.pdf`.

    canvas.init("foo.pdf")
    ar = area.T(...)
    ar.add_plot(...)
    ar.draw()

    canvas.init("bar.pdf")
    ar = area.T(...)
    ar.add_plot(...)
    ar.draw()