472,784 Members | 857 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,784 software developers and data experts.

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 4398
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
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.