On 2015/04/05 11:19 PM, giacomo boffi wrote:
> INTRO
> =====
>
> please consider the following code (I'm trying to draw a timeline)
>
> 1 from matplotlib import pyplot, patches
> 2 fig = pyplot.figure()
> 3 ax = fig.add_subplot('111')
> 4 ax.add_patch(patches.Rectangle((1933,0.25), 73, 0.5))
> 5 pyplot.show()
>
> that gives me a plot with the x axis that goes from 0.0 to 1.0,
> now consider
>
>    ...
> 5 ax.set_xlim((1933,1933+73))
> 6 pyplot.show()
>
> this gives me an x axis that goes _exactly_ from 1933 to 2006,
> eventually drawing a line superposed to the lower spine
>
>    ...
> 5 ax.plot((1933,1933+73),(0,0))
> 6 pyplot.show()
>
> gives me what I really want, that is an x axis running from 1930 to
> 2010, with the limits automatically rounded by matplotlib...
>
> (I noted that the extra line forces a rounding also for the y axis
> limits, but that's not a problem...)
>
> QUESTION
> ========
>
> I want matplotlib to round the limits of the x axis automatically,
> when given explicitly the lower and upper limits of the data, how to?

I think the initial problem is that ax.add_patch() is not triggering the 
autoscaling that you are looking for; the higher-level plot() function 
does so.  After your call to ax.add_patch(), try adding 
ax.autoscale_view().

Eric


>
> Thank you in advance
>


------------------------------------------------------------------------------
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live exercises
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to