473,473 Members | 1,899 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

plotting data against a time axis

Hi,

I have a dictionairy containing DateTime objects as keys and integers as
values. What would be the easiest way to create a simple plot of these,
with a number axis versus a time axis? What library is the most
suitable for this? 'plot' on parnassus yields 18 hits, but since I have
zero experience, I don't know where to start. What makes it difficult
is that I have a time axis instead of a simple integer x-axis. Gnuplot
doesn't seem to be able to do this, or does it?

I could, of course, write the data as a .csv, import it in OpenOffice
and create a chart with OpenOffice, but I don't really see how to get
OOffice to use the first column with iso dates as time axis, and I
want to be able to do this automatically.

yours,
Gerrit Holl.

--
208. If he was a freed man, he shall pay one-third of a mina.
-- 1780 BC, Hammurabi, Code of Law
--
Asperger Syndroom - een persoonlijke benadering:
http://people.nl.linux.org/~gerrit/
Kom in verzet tegen dit kabinet:
http://www.sp.nl/

Jul 18 '05 #1
6 4438
Gerrit Holl fed this fish to the penguins on Saturday 15 November 2003
14:19 pm:
I have a dictionairy containing DateTime objects as keys and integers
as values. What would be the easiest way to create a simple plot of
these, with a number axis versus a time axis? What library is the most
suitable for this? 'plot' on parnassus yields 18 hits, but since I
have zero experience, I don't know where to start. What makes it
difficult is that I have a time axis instead of a simple integer
x-axis. Gnuplot doesn't seem to be able to do this, or does it?

Maybe I need to check the specs of the DateTime module, but most
systems that work in dates usually store them internally in a linear
format. Ignoring the /time/ aspect, a date could be stored in pseudo
human readable format as an 8-digit integer -- yyyymmdd -- which sorts
linearly, regardless of how it is formatted for display.

IOW, time /is/ a integer (or, if using whole dates, a floating point
with time of day as a fraction) counted from some epoch.

At worst, take the earliest (time wise) date in your data as an epoch,
and rebuild your dictionary using the delta from the epoch as the new
key/index.

-- ================================================== ============ <
wl*****@ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG <
wu******@dm.net | Bestiaria Support Staff <
================================================== ============ <
Bestiaria Home Page: http://www.beastie.dm.net/ <
Home Page: http://www.dm.net/~wulfraed/ <


Jul 18 '05 #2
Gerrit Holl <ge****@nl.linux.org> writes:
Hi,

I have a dictionairy containing DateTime objects as keys and integers as
values. What would be the easiest way to create a simple plot of these,
with a number axis versus a time axis? What library is the most
suitable for this? 'plot' on parnassus yields 18 hits, but since I have
zero experience, I don't know where to start. What makes it difficult
is that I have a time axis instead of a simple integer x-axis. Gnuplot
doesn't seem to be able to do this, or does it? gnuplot


G N U P L O T
Version 3.8j patchlevel 0
last modified Wed Nov 27 20:49:08 GMT 2002

Terminal type set to 'x11'
gnuplot> help time
Ambiguous request 'time'; possible matches:
time/date
time_specifiers
timefmt
timestamp

Not what you want?

'as
Jul 18 '05 #3
"Dennis Lee Bieber" <wl*****@ix.netcom.com> wrote in message
news:a6************@beastie.ix.netcom.com...
Maybe I need to check the specs of the DateTime module, but most
systems that work in dates usually store them internally in a linear
format. Ignoring the /time/ aspect, a date could be stored in pseudo
human readable format as an 8-digit integer -- yyyymmdd -- which sorts
linearly, regardless of how it is formatted for display.
Ooops, not really. This trick will correctly *order* dates for sorting, but
they wont ascend linearly. I think that you'll find big non-linear gaps
between the last days of a month and the first day of the next:
20031029
20031030 (delta is 1)
20031031 (delta is 1)
20031101 (delta is 70)
....
20031230
20031231 (delta is 1)
20040101 (delta is 8870!)

At worst, take the earliest (time wise) date in your data as an epoch, and rebuild your dictionary using the delta from the epoch as the new
key/index.

For the OP to get a nice scatter-plot, with linear time as the x-axis
variable, this is what he/she will have to do. Simplest is to contrive an
epoch with a starting day number (01/01/2000?), plus the time represented as
a fraction of a whole day, (so that noon on day 17 will be represented as
17.5, 6pm as 17.75, etc.)
Jul 18 '05 #4
Paul McGuire fed this fish to the penguins on Saturday 15 November 2003
18:58 pm:

Ooops, not really. This trick will correctly *order* dates for
sorting, but
Okay, okay... I did say "readable", whereas ddmmyyyy is all over the
map <G>
For the OP to get a nice scatter-plot, with linear time as the x-axis
variable, this is what he/she will have to do. Simplest is to
contrive an epoch with a starting day number (01/01/2000?), plus the
time represented as a fraction of a whole day, (so that noon on day 17
will be represented as 17.5, 6pm as 17.75, etc.)
Or go to the astronomical format used for Julian date -- where noon is
x.0 and midnight is x.5 (avoids having a 'day' change occur in the
middle of observations -- unless, of course, you are observing sunspots
<G>).

My main interest was that I'd expect almost any time/date module to
have /some/ sort of linear basis available for plotting purposes.

-- ================================================== ============ <
wl*****@ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG <
wu******@dm.net | Bestiaria Support Staff <
================================================== ============ <
Bestiaria Home Page: http://www.beastie.dm.net/ <
Home Page: http://www.dm.net/~wulfraed/ <


Jul 18 '05 #5
Alexander Schmolck wrote:
Gerrit Holl <ge****@nl.linux.org> writes:
zero experience, I don't know where to start. What makes it difficult
is that I have a time axis instead of a simple integer x-axis. Gnuplot
doesn't seem to be able to do this, or does it?

gnuplot


G N U P L O T
Version 3.8j patchlevel 0
last modified Wed Nov 27 20:49:08 GMT 2002

Terminal type set to 'x11'
gnuplot> help time
Ambiguous request 'time'; possible matches:
time/date
time_specifiers
timefmt
timestamp

Not what you want?


Hm, maybe it is, actually :). It seems my estimate was incorrect; to be
fair, I assumed Gnuplot was used solely for plotting functions, not data.
Maybe it is wise to invest some time in learning Gnuplot, I may be happy
with it later as well.

Thank you all (John, Alexander, Dennis, Paul) for the responses!

Gerrit.

--
275. If any one hire a ferryboat, he shall pay three gerahs in money
per day.
-- 1780 BC, Hammurabi, Code of Law
--
Asperger Syndroom - een persoonlijke benadering:
http://people.nl.linux.org/~gerrit/
Kom in verzet tegen dit kabinet:
http://www.sp.nl/

Jul 18 '05 #6
Gerrit Holl <ge****@nl.linux.org> writes:
Alexander Schmolck wrote:
Gerrit Holl <ge****@nl.linux.org> writes:
zero experience, I don't know where to start. What makes it difficult
is that I have a time axis instead of a simple integer x-axis. Gnuplot
doesn't seem to be able to do this, or does it?

gnuplot


G N U P L O T
Version 3.8j patchlevel 0
last modified Wed Nov 27 20:49:08 GMT 2002

Terminal type set to 'x11'
gnuplot> help time
Ambiguous request 'time'; possible matches:
time/date
time_specifiers
timefmt
timestamp

Not what you want?


Hm, maybe it is, actually :). It seems my estimate was incorrect; to be
fair, I assumed Gnuplot was used solely for plotting functions, not data.
Maybe it is wise to invest some time in learning Gnuplot, I may be happy
with it later as well.


I think it is well worthwhile.

I used to regard gnuplot as a waste of time (because of its poor output
quality and a number of bizzarre warts), and because I have matlab available
for plotting (also from within python), which has very comprehensive
functionality.

However I came to appreciate that gnuplot is actually quite useful for quick
and dirty plots, in particular from somewhat messy input files, because
gnuplot helpfully just ignores stuff it can't regard as datapoints. Also its
text based interface, although not perfect, is also far more effective than
most GUI crap, once you got a slight hang of it and saving the plot results in
a file of gnuplot commands which is easy to modify and/or to reuse. Finally
gnuplot has the advantage of being quite ubiquitous and will presumably stay
around for another couple of years.

As a quick example, this will generate a 3D point plot from a text file (that
amongst other things) contains point coordinates in 3 columns (2,3,4).

gnuplot> splot 'locs.xyz' using 2:3:4 with points

Than's to unique prefixes, you'd actually just have to type something like:

gnuplot> sp 'locs.xyz' us 2:3:4 w p

A final word of advice: I'd strongly recommend you track down version 3.8j (or
latter, if already available) -- it has extremely useful enhancements such as
zooming with mouse and decent 3d plots.

'as
Jul 18 '05 #7

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

Similar topics

2
by: Jeff Blee | last post by:
I am hoping someone can help me. I am making a Access 97 app for a person and have run up against a problem to do with MS Graph. There is a table that has a number of data elements and a date field...
1
by: wayne | last post by:
i want to plot a line graph. The values that I obtain are the RGB value of a TIFF image. i m plotting RGB values vs value(1,2,3..) so when generated the RGB values, there will b a column of values...
2
by: sandeepa | last post by:
I am trying to make some kind of a data logger with say 16 channels.So far I have managed to get the data from the serial port and plot it on a chart.(using MSChart)I just store the data of each...
7
by: diffuser78 | last post by:
My python program spits lot of data. I take that data and plot graphs using OfficeOrg spredsheet. I want to automate this task as this takes so much of time. I have some questions. 1. Which is...
0
by: ashraf83 | last post by:
hi guys, i need help plotting chart in Vb, im using SQL to plot the chart but when i use it the first data wont be included in my chart , let say if it was supposed to be data range from 3/1/2006 to...
1
by: Matuag | last post by:
Hi, I want to plot a graph (Audiogram) for frequency (X axis) against intensity (Y axis). Data for which will be sourced from an existing table following frequency fields....
2
by: jlgeris | last post by:
I'm working on an application that graphs data for given time intervals. For example, I could be collecting data in real time, and i'm graphing the last 5 minutes of the data up to the current point....
2
by: Durand | last post by:
Hi, I'm trying to plot a simple graph against date or time using matplotlib. I've read about date_plot but I'm not really sure how to use it. At the moment, I have some data arranged into lists,...
2
by: thanawala27 | last post by:
Hello Friends, I'm new to VB.net, but have been programming from a long time in other languages. I wanted to plot a graph for one of my application in VB.net. I want a Time (X-axis) Vs...
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
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...
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: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
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...

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.