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
Problem
Bar charts are relatively slow because each bar is a separate Rectangle. From a quick check, this scales really linearly with the number of bars N:
N = [30, 100, 300, 1000, 3000, 10000]t = [29, 103, 290, 951, 2860, 9790] # in ms for `plt.bar(x, y)`
While one should not have too many bars in a plot, possibly up to 1000 could be reasonable. The time delay is still okish herem but if e.g. I have multiple subplots, it can become noticable.
Proposed solution
One possible solution is to replace the single Rectangles by a PatchCollection (inspired by#20092).
For backward-compatibility, we'd have to intoduces this gradually similar to what has been done inhist(..., histtype=...)
: Add a parameter to make the created Artist configurable. The default stays on isolated bars, using a collection is opt-in. The default can be switched later.