有没有办法改变颜色和形状来指示 seaborn 箱线图中的平均值?
Is there a way to change the color and shape indicating the mean in a seaborn boxplot?
一个简单的问题,我似乎找不到答案。
如何更改 Seaborn 箱线图中均值指标的颜色和形状?
它默认为绿色三角形,通常很难看到。
我试图在 seaborn 文档和 matplotlib 文档中找到答案。在 Whosebug 上还有一个相关问题,其中有人询问如何更改与 seaborn 箱线图相关的颜色,并且能够更改除均值指标之外的所有内容。
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
data = [[np.random.rand(100)] for i in range(3)]
sns.boxplot(data=data, showmeans=True)
plt.show()
您要查找的关键字参数是meanprops
。它在 matplotlib boxplot documentation 下 "other parameters":
import seaborn as sns
data = [[np.random.rand(100)] for i in range(3)]
sns.boxplot(data=data, showmeans=True,
meanprops={"marker":"s","markerfacecolor":"white", "markeredgecolor":"blue"})
plt.show()
一个简单的问题,我似乎找不到答案。
如何更改 Seaborn 箱线图中均值指标的颜色和形状?
它默认为绿色三角形,通常很难看到。
我试图在 seaborn 文档和 matplotlib 文档中找到答案。在 Whosebug 上还有一个相关问题,其中有人询问如何更改与 seaborn 箱线图相关的颜色,并且能够更改除均值指标之外的所有内容。
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
data = [[np.random.rand(100)] for i in range(3)]
sns.boxplot(data=data, showmeans=True)
plt.show()
您要查找的关键字参数是meanprops
。它在 matplotlib boxplot documentation 下 "other parameters":
import seaborn as sns
data = [[np.random.rand(100)] for i in range(3)]
sns.boxplot(data=data, showmeans=True,
meanprops={"marker":"s","markerfacecolor":"white", "markeredgecolor":"blue"})
plt.show()