Issue
I need to plot a step function in matplotlib (because that's the correct interpretation of my data) and would like to fill between the x-axis and the step curve.
Something like fill_between
, only that this one does not work with drawstyle
.
See minimal example below:
import numpy as np
import matplotlib.pyplot as plt
np.random.seed(2)
x = np.arange(50)
y = np.random.rand(50)
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(x, y, drawstyle='steps-post')
ax.fill_between(x, y, drawstyle='steps-post') # does not work
plt.show()
Solution
You can use ax.fill_between(x, y, step='post')
. fill_between
doesn't have the parameter of drawstyle
.
Answered By - Z-Y.L
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.