plt.bar (matplotlib in python) does not make bars -
i trying make bar plot. have count data have distributed bins of size 1000 (say). on x-axis, have bin coordinate, i.e., -3000, -2000, ..., 0, 1000, 2000, 3000 (in form).
now when plt.bar(x-coord, y-coord), vertical lines.
how make sure bars? did try playing around width coordinate, had no luck.
thank in advance answering question.
your barwidth small. because x values large, bar appears line.
try this:
import numpy np import matplotlib.pyplot plt values = (20, 35, 30, 35, 27, 12, 38) index = np.array((-3000, -2000, -1000, 0, 1000, 2000, 3000)) barwidth = 400 plt.bar(index, values, barwidth) plt.xticks(index + barwidth/2) plt.show()
Comments
Post a Comment