On 05/16/2010 10:19 AM, Philipp K. Janert wrote: > > Let's say I am running an interactive session > (ipython -pylab), and now issue the following > commands: > > x = linspace(0, 10, 100 ) > plot( x, sin(x) ) > ylim( -2, 2 ) > plot( x, cos(x) ) > > Then the second plot command seems to reset > the plot limits to [-1,1] - which makes sense for > the figure, but is not what I requested. > > Is this behavior intended? It seems odd to me, > since generally matplotlib seems to retain state > that has between invocations of plot().
Good question. The control of autoscaling has a somewhat clunky interface via Axes methods, and via the plot function. Your two options are to follow the ylim call with the ugly gca().set_autoscaley_on(False) or to add a kwarg to all subsequent plot calls: plot(x, cos(x), scaley=False) A possible mpl improvement would be to add a kwarg to the pyplot.ylim and xlim functions, e.g. ylim(-2, 2, keep=True) Calling the kwarg "hold" would read better to my eye, but would conflict with the use of "hold" to mean "keep all prior plot elements". Maybe there is a better name, e.g. setting "auto=False" to mean "don't autoscale this on the next plot command". Or "save=True". I suspect we would have to leave the default behavior as it is for continuity and backwards compatibility, although I think that changing it would be an improvement overall. Eric ------------------------------------------------------------------------------ _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users