python-3.x - 使用 Seaborn 填充子图 Python
问题描述
当尝试创建一些子图然后在使用 Seaborn 时填充它们时,我将所有内容都绘制在同一个子图中。这个最小的工作示例完全重现了我的问题。我希望我的 tseries 变量的每个不同的第一个索引都绘制在不同的子图中,因为我认为我的代码通过调用不同的轴来显示。如果您对我犯错误的地方有任何建议,出了什么问题,请告诉我,任何建议都非常感谢!
谢谢!
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
%matplotlib inline
tseries = np.random.random((3,100))
labels = np.random.randint(1,4,100)
fig, ax = plt.subplots(1, 3, figsize = (50,25))
k = 3
for clusteridx in range(1,k+1):
ax[0] = sns.kdeplot(tseries[0,labels==clusteridx],shade=True,label='cluster '+str(clusteridx))
for clusteridx in range(1,k+1):
ax[1] = sns.kdeplot(tseries[1,labels==clusteridx],shade=True,label='cluster '+str(clusteridx))
for clusteridx in range(1,k+1):
ax[2] = sns.kdeplot(tseries[1,labels==clusteridx],shade=True,label='cluster '+str(clusteridx))
解决方案
推荐阅读
- javascript - 为什么复制十六进制值后按空格键颜色不改变?
- json - 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“JSON 写入中的类型无效(MSGraphDateTimeTimeZone)”
- machine-learning - ImageAI 理解输出
- excel - 从调度程序运行时,PowerShell 脚本无法打开 CSV/excel 文件
- html - 将 CSS 样式添加到复选框的父 div
- r - R 编程:用于插补但库错误的 MICE 包 --> 名称空间 'tibble' 但 >= 3.0.0 是必需的
- amazon-mws - 我是一名承包商,为一家在亚马逊上销售的公司工作。我可以使用他们的 MWS 根凭据吗?
- php - 创建 JSON 对象并使用 PHP CURL 访问它在解码时返回空白
- node.js - Mongodb、Reactjs、Express、Node js Heroku 部署显示空白页和 404 错误。在本地工作
- javascript - 在 React 测试库中的 Ant Design Slider 上触发 onChange 函数不起作用