Drawing with Python pychart

Source: Internet
Author: User

1. Install Python:

Download http://download.gna.org/pychart To uncompress and use the command Python setup. py install to install the program.

Home: http://home.gna.org/pychart/ for pychart

For example, the directory I downloaded is c: \ Documents and Settings \ Administrator \ My Documents ents \ downloads \ PyChart-1.39.tar \ PyChart-1.39 \ PyChart-1.39

Installation:

C: \ Documents and Settings \ Administrator \ My Documents ents \ downloads \ PyChart-1.39.tar \ PyChart-1.39 \ PyChart-1.39> Python setup. py install

After installation, If you enable Python >>> import pychart, the installation is successful if no error is reported.

2. Learning documents and examples:

Document: http://home.gna.org/pychart/doc/index.html

Example: http://home.gna.org/pychart/examples/index.html

3 running example:

There are a series of demos in the installation directory of pychart:

C: \ Documents and Settings \ Administrator \ My Documents ents \ downloads \ PyChart-1.39.tar \ PyChart-1.39 \ PyChart-1.39 \ demos.

I thought that the image could be drawn by running it directly. I found that some numbers that I could not understand were printed. So I read the document and found that it was not so interesting.

To produce a postscript chart, just feed the file to Python.

% python linetest.py >linetest.eps

Or, to produce a PDF chart, run Python like below

% python linetest.py --format=pdf >linetest.pdf

The generated PDF file does not have any image or cannot be opened. Therefore, you need to download ghostscript In the FAQ.

Q: Does pychart support windows?
Yes. But you need to install
Pythonand ghostscriptbeforehand.

After installing ghostscript, you must add environment variables to Python.

Example:
From pychart import *
Import sys
Theme. get_options ()

Theme. use_color = true

Can = canvas.init('pic1.png ')

Data = [("foo", 10), ("bar", 20), ("Baz", 30), ("Ao", 40)]

AR = area. t (size = (300,300), legend = legend. t (),
X_grid_style = none, y_grid_style = none)

Plot = pie_plot.t (Data = data, arc_offsets = [0, 10, 0, 10],
Shadow = (2,-2, fill_style.gray50 ),
Label_offset = 25,
Arrow_style = arrow. A3)
Ar. add_plot (PLOT)
Ar. Draw ()

Running result:

To run the built-in example, install the software gsview.

Http://pages.cs.wisc.edu /~ Ghost/gsview/get49.htm

For example, use Python linetest. py> Foo. EPS and then use gsview to open and change the file to view the specific image. However, gsview only supports ps, PDF, and EPs. PNG is not supported. You have to look at how to implement PNG.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.