Issue
plt.rcParams["figure.figsize"] = (40, 40)
fig, axs = plt.subplots(2, 2)
plt.locator_params(axis='x', nbins=6)
axs[0, 0].plot(xcoords, ycoords)
axs[0, 1].scatter(xcoords,ycoords,s=1)
axs[1, 0].bar(xcoords, ycoords)
axs[1, 1].bar(ycoords, xcoords)
plt.show()
First 3 graphs get created as expected, but the fourth one is just blank Screenshot
Any help appriciated
Solution
The default width of a bar for matplotlib.pyplot.bar()
is 0.8. That is usually fine, but if your x-axis runs from 0 to 110.000 or so, that is tiny. So tiny, that Matplotlib will not draw the bars, or more likely, they will not be rendered (and even if they were rendered, you wouldn't be able to see them).
So the data is there, just "invisible".
Increase the bar width. For example:
axs[1, 1].bar(ycoords, xcoords, width=100)
Answered By - 9769953
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.