443,965 Members | 1,631 Online
Need help? Post your question and get tips & solutions from a community of 443,965 IT Pros & Developers. It's quick & easy.

# Creating Pie Chart from Python

 P: n/a Let's say I have the following data: 500 objects: -100 are red -300 are blue -the rest are green Is there some python package which can represen the above information in a pie chart? Thanks Thierry Sep 15 '05 #1
5 Replies

 P: n/a There are many. One choice would be Tkinter's Canvas. def frac(n): return 360. * n / 500 import Tkinter c = Tkinter.Canvas(width=100, height=100); c.pack() c.create_arc((2,2,98,98), fill="red", start=frac(0), extent = frac(100)) c.create_arc((2,2,98,98), fill="blue", start=frac(100), extent = frac(400)) c.create_arc((2,2,98,98), fill="green", start=frac(400), extent = frac(100)) c.mainloop() Jeff -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.6 (GNU/Linux) iD8DBQFDKZK8Jd01MZaTXX0RAuxuAJ9F9jktcSCB3fnQMCUG/9B2Ai+gHwCfbVEx AACjDeSJO/6rj6BCBmirCKo= =QXkW -----END PGP SIGNATURE----- Sep 15 '05 #2

 P: n/a Thierry Lam wrote: Let's say I have the following data: 500 objects: -100 are red -300 are blue -the rest are green Is there some python package which can represen the above information in a pie chart? Thanks Thierry What is the user interface context? Is it a web page? Do you want to create image files with pie chart? If yes to either of these, try gdchart. http://www.icewalkers.com/Linux/Soft...0/GDChart.html http://athani.pair.com/msteed/softwa.../download.html Sep 15 '05 #3

 P: n/a PyChart? Sep 16 '05 #4

 P: n/a >>>>> "Thierry" == Thierry Lam writes: Thierry> Let's say I have the following data: 500 objects: -100 Thierry> are red -300 are blue -the rest are green Thierry> Is there some python package which can represen the above Thierry> information in a pie chart? It looks like in python there is more than one way to make a pie chart. Here's another from pylab import figure, pie, show N, red, blue = 500, 100, 300 green = N - (red + blue) figure(figsize=(6,6)) pie( (red, blue, green), labels=('red', 'blue', 'green'), colors=('red', 'blue', 'green'),) show() A screenshot of a slightly more elaborate example is at http://matplotlib.sourceforge.net/sc....html#pie_demo JDH Sep 16 '05 #5

 P: n/a Those python pie chart add ons are not very useful. For my specific pie chart, I have some 6-8 items to show up and some of them occupy only 2-5% of the pie. This cause the names and percentages to overlap each other. Sep 16 '05 #6

### This discussion thread is closed

Replies have been disabled for this discussion.