我试着在jupyter笔记本上创建一个条形图,x轴是country,y轴是impressions。不知道为什么这些国家被转换成每个国家的指数。也不知道为什么它会创建两个图表,其中一个是空的。有什么办法解决这个问题吗?在
impunder1000 = dataset2.loc[totimps < 1000, ['Total impressions']]
countryunder1000 =dataset2.loc[totimps < 1000, ['Country']]
imp1000 = dataset2.loc[(totimps > 1000) & (totimps < 10000), ['Total impressions']]
country1000 = dataset2.loc[(totimps > 1000) & (totimps < 10000), ['Country']]
imp10000 = dataset2.loc[(totimps > 10000) & (totimps < 100000), ['Total impressions']]
country10000 = dataset2.loc[(totimps > 10000) & (totimps < 100000), ['Country']]
imp100000 = dataset2.loc[(totimps > 100000) & (totimps < 1000000), ['Total impressions']]
country100000 = dataset2.loc[(totimps > 100000) & (totimps < 1000000), ['Country']]
imp1000000 = dataset2.loc[(totimps > 1000000) & (totimps < 10000000), ['Total impressions']]
country1000000 = dataset2.loc[(totimps > 1000000) & (totimps < 10000000), ['Country']]
x = countryunder1000
y = impunder1000
plt.xlabel('Country')
plt.ylabel('Impressions')
plt.title('Countries With Imps Under 1000')
ax = plt.axes()
plt.rcParams["figure.figsize"] = (30,5)
plt.figure
my_plot = x, y.plot(kind='bar')
plt.show()
谢谢!在
您必须按如下方式更改代码才能获得条形图
对于条形图工具中的其他选项,您可以参考文档:https://matplotlib.org/api/_as_gen/matplotlib.pyplot.bar.html
相关问题 更多 >
编程相关推荐