python - 我试图让 X 轴用字符串而不是数字:字符串是(“电影”,“电视节目”),Y 轴用数字填充,直到 8000
问题描述
正如您在标题中所读到的那样,这就是我遇到的问题,不仅如此,我还需要将其绘制为带有两个单独条形的条形图,一个用于电影,一个用于电视节目,这是因为我想显示有多少电影与电视节目之间的差异。
substr = 'Movie'
substr1 = 'TV Show'
print('This are how many movies are in this dataframe:',netflix_df.type.str.count(substr).sum())
print('This are how many TV Show are in this dataframe:',netflix_df.type.str.count(substr1).sum())
输出:
This are how many movies are in this dataframe: 5377
This are how many TV Show are in this dataframe: 2410
我遇到问题的部分
x_ticks_labels = ['Movie','TV Shows']
plt.title('Movies/TV Shows')
plt.hist([netflix_df.type.str.count(substr).sum(),netflix_df.type.str.count(substr1).sum()],
bins = np.arange(x_ticks_labels),
stacked = True);
plt.legend(['TV Show','Movies']);
解决方案
推荐阅读
- python - 在 Tkinter 中使按钮更改自己的颜色
- python - 包装一个 2D numpy 数组
- docker - Jenkins Groovy 字符串插值将秘密解析为 ****
- .htaccess - 如果 url 包含一些特定的单词,htaccess 重定向
- python - 在 python 中将字典与 dfa 库一起使用
- html - 是否可以将鼠标悬停在导航栏中的导航按钮上,显示它的描述?
- mongodb - 区域服务器从附近的 MongoDB 集群节点读取并写入远程 MongoDB 主节点
- python-3.x - 打开带有 NUL 字节的 CSV
- android - 使用滑动手势检测导航栏中的事件
- java - 如何在静态方法结束时返回变量