-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Description
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,shareyandsqueeze(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:
It seems there is a lot of unneccesary(?) clearing happening. Would it be possible to speed this up?
