Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Description
#6915 brings to light two problems with autoscaling:
It looks very inefficient: every plotting method in
_axes
adds an artist to the axes and then callsautoscale_view
, occasionally with arguments.autoscale_view
then does a complete autoscaling operation, going through all of the artists that have been added up to that point. Logically, it seems like the autoscaling should be done only before a draw operation, not every time an artist is added.Beyond the apparent inefficiency, it doesn't work right for collections.
add_collection
callsself.update_datalim(collection.get_datalim(self.transData))
to get dataLim. This uses thepresenttransData
to calculate the size indata units of objects that have sizes and/or positions that may be specified inscreen oraxes units. Then the subsequent call toautoscale_view
uses those positions to modify the view limits. But this changestransData
so that the intended result cannot be achieved--when drawn, the sizes and locations in data units will not be what they were calculated to be when the view limits were set. The mismatch will grow as additional artists are added, each one potentially changing the data limits and the view limits. Usually we get away with this with no one noticing, but not always.plt.yscale('log') after plt.scatter() behaves unpredictably in this example. #6915 shows that subsequently changing the scale of an axis, e.g. linear to log, can wreck the plot.