Thanks to visit codestin.com
Credit goes to github.com

Skip to content

pyplot.subplots() is slow #7163

Closed
Closed
@timhoffm

Description

@timhoffm

matplotlib 1.5.3, Python 2.7.3, Linux (Ubuntu 14.04 LTS), installed using pip

pyplot.subplots() is significantly slower than pyplot.subplot(). This becomes significant when plotting a large number of subplots. For example subplots(40) takes 2.3s whereas 40 calls to subplot() with differing parameters just take 25ms.

Minimal example (using ipython):

import matplotlib.pyplot as plt
%timeit plt.subplots(40)
  • The effect does not depend on the grid: 40x1 is the same as 5x8.
  • The time needed increases linearly with the number of subplots.
  • The effect does not seem to depend on the parameters sharex, sharey and squeeze (though I have not tested all possible parameters)
  • profiling the call reveals that there are a lot of calls to reset_ticks, which use up 75% of the time. See the runsnake screenshot below:

matplotlib_subplots40

It seems there is a lot of unneccesary(?) clearing happening. Would it be possible to speed this up?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions