python - How to change plot from connecting points to vertical sticks? -
the following code create plot connecting points.
import numpy np import matplotlib.pyplot plt x = np.arange(0, 5, 0.1); y = np.sin(x) plt.plot(x, y) plt.show()
how can change plot vertical sticks instead of connecting points? i.e., change type of plot of following example:
thanks.
use plt.bar
import numpy np import matplotlib.pyplot plt x = np.arange(0, 5, 0.1); y = np.sin(x) plt.bar(x, y, width=0.08,edgecolor='none',color='k',align='center') plt.show()
Comments
Post a Comment