Skip to content

Autoscaling has fundamental problems #7413

Closed
@efiring

Description

@efiring

#6915 brings to light two problems with autoscaling:

  1. It looks very inefficient: every plotting method in _axes adds an artist to the axes and then calls autoscale_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.

  2. Beyond the apparent inefficiency, it doesn't work right for collections. add_collection calls self.update_datalim(collection.get_datalim(self.transData)) to get dataLim. This uses the present transData to calculate the size in data units of objects that have sizes and/or positions that may be specified in screen or axes units. Then the subsequent call to autoscale_view uses those positions to modify the view limits. But this changes transData 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.

Metadata

Metadata

Assignees

Labels

Difficulty: Hardhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issuesPerformance

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions