python - 无法使用 subplot 命令组合绘图
问题描述
我有以下简单的熊猫数据框:
A B C D
0 1 8 9 50
1 5 4 1 70
2 7 2 4 90
以下代码用于一个接一个地绘制单独的图形:
df.drop("D", axis=1).plot(kind='bar')
plt.show()
df['D'].plot(kind='bar')
plt.show()
但是,我无法使用suplot命令将这些组合成一个图形:
plt.subplot(211)
df.drop("D", axis=1).plot(kind='bar')
plt.subplot(212)
df['D'].plot(kind='bar')
plt.show()
以下代码生成 2 个图,但只有一个图。没有错误信息。哪里有问题?
解决方案
推荐阅读
- c++ - 创建文件/home/m/OpenCV/modules/core/src/matrix_wrap.cpp,第 1461 行中的空指针(为缺少的输出数组调用 create())
- python - 如何从另一个字符串中删除一个强字符
- oracle11g - 使用 unpivot 从远程表插入
- c++ - 使用 Xamarin.Forms 调用本机 C/C++ 代码
- highcharts - 动态添加值时,Highcharts 保持缩放
- python - 我可以对两个不同的列进行条件排序,但是根据次要条件将两列的顺序颠倒了吗?
- php - 抓取 Facebook 页面以获得页面喜欢
- rust - 在盒装的未来使用参考变量时“需要显式生命周期”
- ruby-on-rails - 在 Rails 设置中无法解决过去的错误-`LoadError:无法加载此类文件--active_storage/engine`
- sql-server - 如何使用 SSIS 包每小时仅将一行从 Excel 插入 SQL Server 表