From: John H. <jdh...@ac...> - 2004-08-03 13:40:02
|
>>>>> "Vineet" == Vineet Jain <vi...@al...> writes: Vineet> That's fine. I'll start using Vineet> ax.viewLim.intervaly().get_bounds() # the y limits Vineet> to get the y limits. Hi Vineet, This is not recommended. I pointed you to limit attributes these so you can compare what is happening with the data and view limits separately, and to give you some insight into how to poke around if you need to. There is no reason for you to call ax.viewLim.intervaly().get_bounds() since this is what get_ylim calls anyway. The set_ylim and get_ylim functions are fixed as part of the matlab API; The viewLim and dataLim attributes are not. When possible, stick with the documented API, so your code will be compatible with future matplotlib releases. Vineet> In any case though, the order in which the plot functions Vineet> are called should not change the value returned by Vineet> self.axMiddle.get_ylim. I think that is a bug. There may be a bug, but let's be clear to find out. Here is what is happening. Every time you issue a plot command, the ax.dataLim are updated. These should exactly bound the min and max of the x and y range of your data. After that, ax.autoscale_view is called. This updates the min and max of the x and y *view* limits, which should include, but may exceed, the datalim. Exactly how this view limit update is done depends on the tick locator you have chosen. The default locator is matplotlib.ticker.AutoLocator, but you can customize this. if you issue repeated plot commands ax.plot(something) ax.plot(something_else) ax.plot(still_mode) print 'datalim', ax.dataLim.intervaly().get_bounds() print 'viewlim', ax.get_ylim() neither the viewlim nor the datalim after all plot commands have been issued should not be affected by the order of the plot commands. Of course, you need to apply the patch I posted in my previous email (to the has_data function) because there was a bug. The viewlim *will* be changed after each plot command, and will depend on the order, as in ax.plot(something) print 'viewlim', ax.get_ylim() ax.plot(something_else) print 'viewlim', ax.get_ylim() ax.plot(still_mode) print 'viewlim', ax.get_ylim() but again, the final viewlim should be order independent. Is this what you observe? If the plot order does affect the final limits, let me know. If the viewlim differs from the data lim, that is unsurprising, as that is by design. If you are unhappy with the way to the autolocator is choosing the view limits, you have a couple of choices: 1) let me know by giving me the requisite datalim and viewlim boundaries, what is happening, and what you think should be happening and I'll look in to fixing it or 2) use a custom locator that autoscales the view limits in the way you want. JDH |