473,804 Members | 2,148 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Creating Pie Chart from Python

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 7529
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)

iD8DBQFDKZK8Jd0 1MZaTXX0RAuxuAJ 9F9jktcSCB3fnQM CUG/9B2Ai+gHwCfbVEx
AACjDeSJO/6rj6BCBmirCKo=
=QXkW
-----END PGP SIGNATURE-----

Sep 15 '05 #2
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
PyChart?

Sep 16 '05 #4
>>>>> "Thierry" == Thierry Lam <la********@gma il.com> 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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1963
by: kdahlhaus | last post by:
Does anyone here have experience with Chart Director (http://www.advsofteng.com/index.html)? I'm thinking about purchasing it and looking for any feedback from the Python community. Thanks
1
4368
by: Alan | last post by:
Hi there, Are there Excel charting gurus here?? If so then please read on... Sorry for the cross-post but I'm not familiar with the Excel groups. I've posted to asp.general because if I have to code a solution to this it'll probably be done in ASP on a web server, unless there's a significantly better way. I'm looking for a way to create over 100 Excel *charts* programmatically.
5
3206
by: Alan | last post by:
Hi there, Are there Excel charting gurus here?? If so then please read on... Sorry for the cross-post but I'm not familiar with the Excel groups. I've posted to asp.general because if I have to code a solution to this it'll probably be done in ASP on a web server, unless there's a significantly better way. I'm looking for a way to create over 100 Excel *charts* programmatically.
6
3682
by: Martin Magnusson | last post by:
I'd like to create my own output streams, in order to be able to redirect output strings to a console, a status window or whatever, depending on the environment. For example, IO::warning << "Bad stuff"; could output a string on stderr to start with, and when I have written a nice GUI, it could be output to a status window or a log file or something. I have written a skeleton file which looks like this: //---------------------
2
2802
by: Homer | last post by:
Hi, Have a quick question: Lets say I have a Hashtable of values hence 56 37.890 1 12.768 5 9.764 etc.... Is there a way for me to draw a chart in C# of this. FYI its actually lottery numbers and the percentages of how often they have repeated. I fugured this would be a good
9
3098
by: Patrick.O.Ige | last post by:
I have a code below and its a PIE & BAR CHART. The values now are all static but I want to be able to pull the values from a database. Can you guys give me some ideas to do this? Thanks Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Declare your object variables
1
7642
by: Robin Tucker | last post by:
Heres and interesting problem: I have a VB.NET program that creates reports via. Word Automation. This all works fine. What I want to do as part of this report generation process is to embed a graph/chart within the report, once again from VB.NET. I have chosen to use Excel.Chart.8. So, to embed I do this from VB.NET: Dim theNewShape As InlineShape = m_Document.InlineShapes.AddOLEObject (ClassType:="Excel.Chart", _
3
13608
by: implicate_order | last post by:
Greetings, I'm new to python and am in the process of writing a script to parse some CSV data, spread it across multiple Excel worksheets and then generate charts. I searched the internet to find some place where I could look up a HOWTO doc/recipe to do that using either pyExcelerator or win32com.client. Could someone point me in the right direction? I'm at the stage where the spreadsheet and associated data worksheets
5
10435
by: Kuna | last post by:
Hi All, I am trying to create a gantt chart in php by getting data from database. I am using WindowsXp OS and having php-4 and my-sql DB. I have installed the JPGRAPH package to my system and including the jpgraph modules accordingly. I am able to create a gantt chart by hardcoding the datas but when I am trying to get the data from database then I am not able to get the chart it is showing errors. I think thre might be some problem in...
0
9712
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9594
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10595
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10343
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10089
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7634
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5530
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.