473,472 Members | 2,124 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Phython and graphing

Hello,

Can someone lead me to an easy way to create a graph in Python.

For example, I have a script running that creates a list of dates,
times and values. I would like to turn this into a graph.

I can grep the info into a new file creating two columns (x,y) but the
issue is the graph.

P.S. I'm a Python newbie so keep that in mind.

Thanks in advance...

Apr 20 '06 #1
3 3214
In article <11**********************@v46g2000cwv.googlegroups .com>,
"mostro" <Ad******@gmail.com> wrote:
Hello,

Can someone lead me to an easy way to create a graph in Python.

For example, I have a script running that creates a list of dates,
times and values. I would like to turn this into a graph.

I can grep the info into a new file creating two columns (x,y) but the
issue is the graph.

P.S. I'm a Python newbie so keep that in mind.

Thanks in advance...


google matplotlib nice package. I've been told that another package
called wsMpl.py also puts a nice API on the matplotlib. You might want
to check that, too.

-- Lou Pecora (my views are my own) REMOVE THIS to email me.
Apr 21 '06 #2
mostro wrote:
Hello,

Can someone lead me to an easy way to create a graph in Python.

For example, I have a script running that creates a list of dates,
times and values. I would like to turn this into a graph.

I can grep the info into a new file creating two columns (x,y) but the
issue is the graph.

P.S. I'm a Python newbie so keep that in mind.

Thanks in advance...

Another possibility would be ReportLab Graphics (www.reportlab.com).
It can create bar charts, line graphs, etc. It is lesser known than
its big brother ReportLab PDF generator, but works equally well. In
addition, it works well if you want to put graphs into .PDF documents.

-Larry Bates
Apr 21 '06 #3
>>>>> "mostro" == mostro <Ad******@gmail.com> writes:

mostro> Hello, Can someone lead me to an easy way to create a
mostro> graph in Python.

mostro> For example, I have a script running that creates a list
mostro> of dates, times and values. I would like to turn this into
mostro> a graph.

mostro> I can grep the info into a new file creating two columns
mostro> (x,y) but the issue is the graph.

mostro> P.S. I'm a Python newbie so keep that in mind.

Here's an example from the matplotlib examples dir

http://matplotlib.sf.net/examples

that does just that. It loads dates and values from a file using the
load function, and then plots them with the plot_date command

The delimiter directive in the load command says to use comma
separated values. The converters arg is a dictionary mapping column
number to a function that converts that column to a float (datestr2num
converts date strings to matplotlib dates using the wonderful
dateutil.parser.parse function that can convert just about any date
string -- the default column converter is 'float'). skiprows
indicates that there is a single line of header to convert, and
usecols says to take the first and third columns.

The rest is easy -- just call plot_dates:

from pylab import figure, show, datestr2num, load
dates, closes = load(
'data/msft.csv', delimiter=',',
converters={0:datestr2num}, skiprows=1, usecols=(0,2),
unpack=True)

fig = figure()
ax = fig.add_subplot(111)
ax.plot_date(dates, closes)
show()
Here is a brief look at the data file being plotted:

Date,Open,High,Low,Close,Volume,Adj. Close*
19-Sep-03,29.76,29.97,29.52,29.96,92433800,29.79
18-Sep-03,28.49,29.51,28.42,29.50,67268096,29.34
17-Sep-03,28.76,28.95,28.47,28.50,47221600,28.34
16-Sep-03,28.41,28.95,28.32,28.90,52060600,28.74
15-Sep-03,28.37,28.61,28.33,28.36,41432300,28.20
..... and many more
JDH
Apr 21 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Michael T. Peterson | last post by:
Would anyone care to recommend a good graphing package (commercial or otherwise)? I've looked at some of the PEAR Image packages - The only graphing package is still alpha quality. One...
4
by: FGO | last post by:
Hi all, I use jpgraph as a graphing tool and it is very slow. Is there a solution to tune it or will I have to use another graphing solution, and which one? (My graphs are simple line stocks...
2
by: john | last post by:
Are there any charting or graphing modules for python that can write PNG, JPEG, or GIF graphics? I have found a couple of nice looking packages that can make beautiful postscript, PDF, or SVGs...
22
by: Kenneth Miller | last post by:
Hello All, I am new to Python and i was wondering what graphing utlities would be available to me. I have already tried BLT and after weeks of unsuccesful installs i'd like to find something...
6
by: Michael Hill | last post by:
Hello, all. I am considering writing an online graphing utility. I plan it to be of good quality, such that an undergraduate university student can print it out and include it with a lab report....
1
by: Mudcat | last post by:
Hi, I have looked through the previous suggestions on graphing modules and have been able to find some good suggestions. However I was wondering about something more specific. I am going to...
1
by: robby.walker | last post by:
Hi, I've just released a full-featured online graphing calculator at http://www.e-tutor.com/et2/graphing/ It requires no downloads or plugins - just JavaScript. You can track points on the...
0
by: Dexter | last post by:
GraphEasyRect was previously available as an applet. Now we have converted it to a desktop standalone application that runs on multiple platforms Windows, Mac, and Linux This tool allows...
2
by: sydneytroz | last post by:
I am writing a program to simulate a double displacement reaction getting to equilibrium, but I am having some trouble graphing the particles' concentrations. It seems that it's only possible to pan...
1
by: skeates | last post by:
Hey all - I'm attempting to write a program that accesses a database, runs some calculations according to user input, and then creates some graphs from the results. The first two steps were pretty...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
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...
0
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...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.