Description
Bug report
Bug summary
As I updated Matplolib from version 3.0.3 to version 3.3.0 I noticed that Colour unit test time skyrocketed: our plotting sub-package test suite went from 120 seconds to around 3000 seconds!
I quickly noticed that it was related to definitions using the spectrum plot:
This definition is using plt.bar
and as I suspected that polygon clipping might be the culprit, I ran some tests on one of the offending definitions while keeping and removing the polygon clipping:
With Polygon Clipping
>>> import timeit
>>> import colour
>>> timeit.timeit(lambda : colour.plotting.plot_single_illuminant_sd(filename='test.png'), number=1)
59.81594165299998
Without Polygon Clipping
>>> import timeit
>>> import colour
>>> timeit.timeit(lambda : colour.plotting.plot_single_illuminant_sd(filename='test.png'), number=1)
1.3159556400000056
Code for reproduction
I haven't created a reproducible case but my assumption is that the clipping code is orders of magnitude slower than before, the definition I used is available here: https://github.com/colour-science/colour/blob/d5f68005f62fc86ba59745bd4c8bb8a01bb5dcb4/colour/plotting/colorimetry.py#L183 and the meat is roughly as follows:
polygon = Polygon(
np.vstack([
(x_min, 0),
tstack([wavelengths, values]),
(x_max, 0),
]),
facecolor='none',
edgecolor='none')
axes.add_patch(polygon)
padding = 0.1
axes.bar(
x=wavelengths - padding,
height=max(values),
width=1 + padding,
color=colours,
align='edge',
clip_path=polygon)
There are roughly 450 wavelengths and each one of them generates a coloured bar.
Matplotlib version
- Operating system: macOS 10.15.5
- Matplotlib version: 3.3.0
- Matplotlib backend (
print(matplotlib.get_backend())
): MacOSX - Python version: 3.8
- Jupyter version (if applicable):
- Other libraries:
Matplotlib was installed with Pip.