[Matplotlib-users] xlim with dates

2010-03-12 Thread Alex S

Hi there, does anyone know if there's a simple way to set an axis limit to a
date?  viewlim_to_dt() looks promising, but I can't figure out how to use
it...

Thanks a lot,
Alex
-- 
View this message in context: 
http://old.nabble.com/xlim-with-dates-tp27881612p27881612.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] xlim with dates

2010-03-12 Thread othererik


Alex S wrote:
 
 Hi there, does anyone know if there's a simple way to set an axis limit to
 a date?  viewlim_to_dt() looks promising, but I can't figure out how to
 use it...
 
 Thanks a lot,
 Alex
 

Alex,

I've done something like this in the past:
ax.set_xlim( ( min_val, max_val ) )
# improve formatting
fig.autofmt_xdate( bottom = 0.20001, rotation = 30,
ha = 'right' )

where min_val and max_val are values from
matplotlib.dates.date2num( dt ) because
dt is a datetime object, which is not the format matplotlib
uses. 

So, setting the xlimit ( or ylimit )  using the values expected by
matplotlib manually is one option.

def date2num(d):

*d* is either a :class:`datetime` instance or a sequence of datetimes.

Return value is a floating point number (or sequence of floats)
which gives number of days (fraction part represents hours,
minutes, seconds) since 0001-01-01 00:00:00 UTC.


-Erik

-- 
View this message in context: 
http://old.nabble.com/xlim-with-dates-tp27881612p27882067.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] xlim with dates

2010-03-12 Thread Alex S

Ah perfect, thanks a lot, sorry for the mundane question :)
-- 
View this message in context: 
http://old.nabble.com/xlim-with-dates-tp27881612p27882177.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] xlim with dates

2010-03-12 Thread Ryan May
On Fri, Mar 12, 2010 at 1:15 PM, Alex S schmitt.happ...@gmail.com wrote:
 Hi there, does anyone know if there's a simple way to set an axis limit to a
 date?  viewlim_to_dt() looks promising, but I can't figure out how to use
 it...

If you've plotted using dates, just use dates for the limits:

import matplotlib.pyplot as plt
import numpy as np
from datetime import datetime, timedelta
s = datetime.now()
x = np.array([s, s + timedelta(hours=3)])
y = np.arange(1,3)
plt.plot(x,y)
plt.xlim(s - timedelta(minutes=30), s + timedelta(hours=4))
plt.show()

Ryan

-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma

--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users