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

enter image description here

how can change plot vertical sticks instead of connecting points? i.e., change type of plot of following example:

enter image description here

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

enter image description here


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -