[Matplotlib-users] set fixed xrange

2009-04-23 Thread Till Backhaus
Hi there,

I'm using matplotlib (version 0.98.5.2) to generate a couple of bar- 
charts for a website.
Until now I've not been able to find a way set the x axis to a fixed  
range.

Suppose my data is turnover per hour. Now: If there is zero turnover  
at the beginning
or the end of a period matplotlib omits that value and limits the  
xrange so that non-zero
hours reside on the edges which would be confusing for the users.

This is the code:
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
fig = plt.figure(figsize=(5,4),dpi=72)
ax = fig.add_subplot(111)
ax.set_ylabel('EUR')
ax.set_xlabel('Hour')
ax.set_xlim((1,24))
ax.bar(data.keys(),data.values(),width=1,align='center')
fig.savefig(filename)

I searched the docs but I didn't find anything that could fix my  
problem.
It would be great if anybody knew (and told me) what I am doing wrong.

Thanks in advance

Till Backhaus

--
Stay on top of everything new and different, both inside and 
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today. 
Use priority code J9JMT32. http://p.sf.net/sfu/p
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] set fixed xrange

2009-04-23 Thread Ryan May
On Thu, Apr 23, 2009 at 8:40 AM, Till Backhaus t...@backha.us wrote:

 Hi there,

 I'm using matplotlib (version 0.98.5.2) to generate a couple of bar-
 charts for a website.
 Until now I've not been able to find a way set the x axis to a fixed
 range.

 Suppose my data is turnover per hour. Now: If there is zero turnover
 at the beginning
 or the end of a period matplotlib omits that value and limits the
 xrange so that non-zero
 hours reside on the edges which would be confusing for the users.

 This is the code:
 import matplotlib
 matplotlib.use('Agg')
 import matplotlib.pyplot as plt
 fig = plt.figure(figsize=(5,4),dpi=72)
 ax = fig.add_subplot(111)
 ax.set_ylabel('EUR')
 ax.set_xlabel('Hour')
 ax.set_xlim((1,24))
 ax.bar(data.keys(),data.values(),width=1,align='center')
 fig.savefig(filename)


Try moving the call to ax.set_xlim to *after* the call to ax.bar.

Ryan

-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
Sent from Norman, Oklahoma, United States
--
Stay on top of everything new and different, both inside and 
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today. 
Use priority code J9JMT32. http://p.sf.net/sfu/p___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users