python-3.x - 如何绘制共享相同 x 轴的 2 个子图
问题描述
所以目前我有一个scatterplot
和一个kdeplot
我使用 seaborn 库来绘制的。
这是我绘制图表的方式:
# plot a graph to see the zipcodes vs the density
plt.figure(figsize=(16,8))
sns.kdeplot(king['zipcode'], shade=True, legend=False)
plt.xlabel('Zipcode')
plt.ylabel('Density')
plt.figure(figsize=(16,8))
sns.scatterplot(king['zipcode'],king['price'])
但是当我尝试做一个子图时,我的 kdeplot 似乎消失了: 我试图这样做:
f, axarr = plt.subplots(2, sharex=True)
sns.kdeplot(king['zipcode'], shade=True, legend=False)
sns.scatterplot(king['zipcode'],king['price'])
是否可以在子图中正确渲染两个图形?
解决方案
推荐阅读
- .htaccess - 拒绝从 htaccess 中的引用者中的特定单词访问
- css - 媒体查询不适用于移动设备
- java - JavaFX - 当模型包含列表时如何动态绑定 TableView
- jquery - 在 jquery 中自动完成搜索
- puppet - 因素 - 如何检查目录是否存在
- python - Python3 [类] - 我应该创建一个新变量来存储来自用户输入的类的实例,以及如何?
- haskell - WAI 教程 - 没有实例(显示响应)
- javascript - 如何使用 JavaScript 在 TypeORM 中使用 Active Record 模式
- azure - 带有 Azure 应用程序网关和虚拟机的 Azure DevOps 发布管道
- python - Pivoting python