我想在地点和该地点的公司数量之间绘制一个图表
# split data on basis of group
location_group = fortune_df.groupby('Location')
# pick top 10 location with maximum location
location_withmax_no_of_companies = location_group.size().sort_values(ascending = False)[:10]
Location
New York, NY 72
Houston, TX 44
Atlanta, GA 23
Chicago, IL 22
Dallas, TX 16
St. Louis, MO 14
San Francisco, CA 11
Cleveland, OH 11
San Jose, CA 10
Columbus, OH 10
dtype: int64
lpos = np.arange(10)
plt.xticks(lpos,location_withmax_no_of_companies)
plt.bar(lpos,location_withmax_no_of_companies)
我想要位置的名称而不是数字(x轴),但不知道如何在x轴上给出名称。任何线索都会有帮助
可以使用熊猫来绘制^{} :
或将
location_withmax_no_of_companies
更改为location_withmax_no_of_companies.index
,以便通过Series
的索引更改标签:如果还需要旋转标签:
相关问题 更多 >
编程相关推荐