You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the .set_drawstyle method of a matplotlib.lines.Line2D fails if this line has been produced via plt.plot(). If the line is produced via plt.Line2D and subsequently added to the canvas, the output is as expected.
The following demonstrates this. We would expect to see the same step-like line in both subplots, but the right subplot, showing a line produced via plot, ignores its drawstyle.
import matplotlib.pyplot as plt
import numpy as np; np.random.seed(1)
x = np.linspace(0,1,20)
y = np.random.rand(len(x))
fig, (ax,ax2) = plt.subplots(ncols=2, figsize=(6,2.8))
line = plt.Line2D(x,y)
ax.add_artist(line)
line.set_drawstyle("steps-pre") # <-- this gives the desired step function
line2, = ax2.plot(x,y)
line2.set_drawstyle("steps-pre") # <-- this fails
plt.show()
[This is reproduced with matplotlib 2.1.2 on python 2.7 (64bit), windows 8.1 (64bit), both with TkAgg and Qt4Agg]
The text was updated successfully, but these errors were encountered:
Line2D.set_drawstyle needs to add either self._invalidx = True or self._invalidy = True to trigger a recache of the path; that fixes the issue. (Actually this will also cause a useless round through the unit machinery because it's not actually the x or y values that have become invalid, but right now there's no way to say "it's the drawstyle that has become invalid" (well, perhaps add a new flag).
Using the
.set_drawstyle
method of amatplotlib.lines.Line2D
fails if this line has been produced viaplt.plot()
. If the line is produced viaplt.Line2D
and subsequently added to the canvas, the output is as expected.The following demonstrates this. We would expect to see the same step-like line in both subplots, but the right subplot, showing a line produced via
plot
, ignores its drawstyle.[This is reproduced with matplotlib 2.1.2 on python 2.7 (64bit), windows 8.1 (64bit), both with TkAgg and Qt4Agg]
The text was updated successfully, but these errors were encountered: