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
Bug report
Sketch transformation has identical pseudo-random output for identical inputs
The sketch transformation (such as used in xkcd) produces exactly the same randomized result if the same path is plotted repeatedly. This is visible especially in the legend, where the rectangle patch is repeated for each item. I exaggerated randomness and scale to make the effect better visible.
As far as I can see, the culprit is in the built-in RNG which gets re-seeded to 0 for each Sketch instantionation:
matplotlib/src/path_converters.h
Line 941 ine02f2c5
m_rand(0) |
importmatplotlib.pyplotaspltwithplt.xkcd(randomness=40,scale=1):importmatplotlibfrommatplotlibimportgridspecpat,txt=plt.pie([10,20,30,40],wedgeprops={'edgecolor':'black'})plt.legend(pat,['first','second','third','fourth'],loc='best')
zoom on the legend:
Expected outcome
Shapes are distored randomly, e.g. each rectangle in the legend is different.
Matplotlib version
- Operating system: Ubuntu 18.04
- Matplotlib version: 2.2.2
- Matplotlib backend (
print(matplotlib.get_backend())
): TkAgg - Python version: 3.6.7
- Jupyter version (if applicable): [none]
- Other libraries:
installation: default packaged matplotlib installation (python3-matplotlib).