matplotlib - 有什么方法可以从seaborn fiddle 图中得到迷你箱线图吗?

标签 matplotlib jupyter-notebook seaborn

我正在尝试绘制一系列很长的箱线图。我喜欢里面绘制的微型箱线图的美感 violinplot (通过seaborn.violinplot 的“inner”参数控制)。有谁知道有一种简单的方法可以只绘制这个迷你箱线图而无需绘制 fiddle 图的其余部分?谢谢!

seaborn violin plots

最佳答案

fiddle 是PolyCollection对象。您可以从轴中删除所有PolyCollection。如果轴仅包含 fiddle 图而不包含任何其他 PolyCollection,则这是有意义的。

import matplotlib.pyplot as plt
import seaborn as sns

sns.set(style="whitegrid")
tips = sns.load_dataset("tips")
ax = sns.violinplot(x="day", y="total_bill", data=tips)


from matplotlib.collections import PolyCollection
for a in ax.findobj(PolyCollection):
    a.remove()

ax.relim()
ax.autoscale_view()

plt.show()

enter image description here

或者更简单,

for a in ax.collections:
    a.remove()

关于matplotlib - 有什么方法可以从seaborn fiddle 图中得到迷你箱线图吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52971882/

相关文章:

python - matplotlib/seaborn : first and last row cut in half of heatmap plot

python - Matplotlib 的非线性颜色图

python - Matplotlib 文本对齐

python - Matplotlib 共享 y 轴 - 一个子图未对齐

python - 如何使用 Windows 操作系统从 .pkl 文件获取数据

linear-regression - 拟合回归后如何使用Seaborn的residplot?

python - 如何在带有分类轴的条形图上叠加数据点

python - Pandas - 根据 A 列中的值访问 B 列中的值

python - Pycharm jupyter单元格背景

python - 从 Seaborn Boxplot 中提取异常值