I wrote a response that seemed to disappear. Let's try again.

Matplotlib is a fair suggestion. What about Scipy?

Your suggested way of converting datetime objects into a single number
seems very flimsy to me. I have been programming with dates and times
for years (though never before in Python), and writing programs like
the ones you suggested seems good in theory, but never stands up in
practice. The problem might be leap years, or 12 PM's (which should be
0 PM), or something like that which I can't foresee.

Luckily, I found an alternative means of translating:

>>>Import datetime, time

>From datetime to UNIX time
(from (2008, 9, 25, 5, 45, 31) to 1222334412.0):

>>> dateTimeObject = datetime.datetime(2008, 9, 25, 5, 45, 31)
>>> unixTimeNumber = time.mktime(dateTimeObject.timetuple())
>>> print unixTimeNumber
1222334412

>From UNIX time to datetime
(from 1222334412.0 to (2008, 9, 25, 5, 45, 31)):

>>> unixTimeNumber = time.time()  #this gives the current time
>>> dateTimeObject = datetime.datetime.fromtimestamp(unixTimeNumber)
>>> print dateTimeObject
datetime.datetime(2008, 9, 25, 5, 45, 31)

Important notes: The UNIX timestamp is in seconds since 1970.

Does anyone see any problems with this?

And my final question is how to get it to actually write "January" on
the graph. Figuring out that it is January is the easy part, how do I
write it along the bottom of the graph?

Thanks.

On Sep 25, 3:28 am, "Dalius Dobravolskas"
<[EMAIL PROTECTED]> wrote:
> Hello,
>
> > 1. What libraries/modules should I be using to draw these graphs?
>
> matplotlib
> Samples:http://www.google.lt/search?q=matplotlib+pylons
>
> > 2. Is there any plotting library that understands datetime objects,
> > and can graph them intelligently?
>
> > If the answer to 2 is no...
>
> I don't know.
>
> > 3. How can I turn a datetime object (essentially six numbers) into a
> > single floating point number? For instance, Friday at 1 PM is 6.93,
> > and Friday at 3 PM is 7.71, or something like that which will be
> > possible to graph. Know what I mean? I need to translate/transform a
> > datetime object into a single number that will create a non-distorted
> > graph when that number is used as the X-value for an event (data
> > point).
>
> 1. Convert datetime object to timestamp object.
> 2. Convert previous Monday or Sunday to timestamp (is in seconds).
> 3. Subtract one from another and divide them by number of seconds in
> day (or whatever you want).
>
> > 4. How can I change the labels on the X-axis to say Friday, 1 PM,
> > instead of saying 6.93.
>
> I guess 1 PM is more like 6.54 or even 5.54 or 4.45.
> 1) int(5.54) => 5.
> 2) {0: 'Sunday', 1: 'Monday'....
> 3) round((5.54-int(5.54))*24) -> 13 ...
>
> > Thank you. Also, if I have to do 3 and 4 I will be really, really sad.
>
> Don't be lazy ;-)
>
> --
> Daliushttp://blog.sandbox.lt

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to