Skip to content

path randomness is repetitive (sketch RNG seeded to 0 for each path anew) #13479

Open
@eudoxos

Description

@eudoxos

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:

.

import matplotlib.pyplot as plt
with plt.xkcd(randomness=40,scale=1):
    import matplotlib
    from matplotlib import gridspec
    pat,txt=plt.pie([10,20,30,40],wedgeprops={'edgecolor':'black'})
    plt.legend(pat,['first','second','third','fourth'],loc='best')

Actual outcome
image

zoom on the legend:

image

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    keepItems to be ignored by the “Stale” Github Action

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions