matplotlib - 将多个 seaborn.catplot 堆叠在一起
问题描述
我有多个使用 Seaborn 的不同 FacetGrid 图(来自无法合并的不同数据框)。
每个地块是
g = sns.catplot(x="type", y=outcome,
hue="team",
order=types
,ci=68.2,
kind="point",aspect=1.3,
data=df_temp)
我想将它们堆叠在一起,以便在同一斧头上拥有一个同时具有 HH 和 MH 值的图。要得到这样的东西:
我尝试fig = plt.figure()
在循环外部然后fig.axes.append(g.ax)
在循环内部(超过 6 个数据帧)但没有成功(我在 fig.axes 中得到一个空数组)
有没有办法做到这一点?
解决方案
尝试通过轴ax
。catplot
不接受ax
参数。
编辑:根据您自己的建议,pointplot
通过轴实例时有效ax
。
fig = plt.figure(figsize=(8,6))
ax = fig.add_subplot(111)
g = sns.pointplot(x="type", y=outcome, hue="team", order=types,
ci=68.2,data=df_temp, ax=ax)
推荐阅读
- javascript - 在一个图中为多个图形自定义工具提示
- python - 用python解决一道数学题:求和一个尽可能接近的值
- python - 如何保持 kwarg 的 dtype 完整?
- python-3.x - Scrapy爬虫不下载文件?
- sql - 使用 Distinct 的语句的 SQL 调优(优化)
- java - 带有映射的自定义 JOLT 转换
- python - 星图比嵌套列表理解更快吗?
- python - 在heroku上安装nltk包时出错
- javascript - Javascript添加前导零适用于while循环但不适用于for循环
- json - 具有动态颜色的自定义 GitHub 徽章