0

I am trying to plot the population of lots of cities using a histogram. There is over 7000 cities and the populations range from around 5000 to 19,000,000. I am unfamiliar with the np.hist command and have tried playing around with it and the bins and with logarithmic scales to create a nice graph but have not been successful. The following is the code I used to obtain this graph but for some reason it seems to be plotting the populations on the x axis, I thought they would have appeared vertically?

plt.hist(pop_usa)
plt.yscale('log')
plt.show()

Graph attached here

MarianD
  • 13,096
  • 12
  • 42
  • 54
  • Does this answer your question? [plotting a histogram on a Log scale with Matplotlib](https://stackoverflow.com/questions/47850202/plotting-a-histogram-on-a-log-scale-with-matplotlib) – Michael Szczesny Oct 12 '20 at 12:58
  • Did you try `plt.hist(...,orientation='horizontal')`? [docs](https://matplotlib.org/3.3.2/api/_as_gen/matplotlib.pyplot.hist.html). This would need `plt.xscale('log')` for the example in the post. – JohanC Oct 12 '20 at 15:19

0 Answers0