I noticed something weird. When I make a link chart with drawstyle parameter, it works. For example
import matplotlib.pyplot as plt
x = np.linspace(10, 24, 10)
y = np.random.randn(10)
fig, ax = plt.subplots()
ax.plot(x, y, drawstyle="steps")
However, if I want to set it with, say,
ax.lines[0].set_drawstyle('steps')
It does not work at all. Instead a line without steps is shown.
Any clues?
There is now a fix to this bug on its way.
Until this finds its way into the next release of matplotlib, you may apply it manually. The solution is to add line._invalidx = True
to force the line being recached.
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(10, 24, 10)
y = np.random.randn(10)
fig, ax = plt.subplots()
line, = ax.plot(x, y)
line.set_drawstyle("steps-pre")
line._invalidx = True
plt.show()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.