我正在尝试更改Seaborn中小提琴的边缘颜色。下面的代码为我工作。
ax=sns.violinplot(data=df, x="#", y="SleepAmount", hue="Thr", palette=my_pal, split=True,linewidth = 1, inner=None)
ax2 = sns.pointplot(x="#", y="SleepAmount", hue="Thr", data=df, dodge=0.3, join=False, palette=['black'], ax=ax,errwidth=1, ci="sd", markers="_") plt.setp(ax.collections, edgecolor="k")
plt.setp(ax2.collections, edgecolor="k")
Run Code Online (Sandbox Code Playgroud)
但是当我使用facetgrid时,我不知道如何采用plt.setp(ax.collections, edgecolor="k")下面的facetgrid地图。
g = sns.FacetGrid(df, col="temperature",sharey=True)
g=g.map(sns.violinplot,"#", "latency", "Thr", palette=my_pal, split=True, linewidth = 1, inner=None,data=df)
g=g.map(sns.pointplot, "#", "latency", "Thr", data=df, dodge=0.3, join=False, palette=['black'],errwidth=1, ci="sd", markers="_")
Run Code Online (Sandbox Code Playgroud)
我已经尝试了很多东西。喜欢,
sns.set_edgecolor('k')
sns.set_style( {"lines.color": "k"})
sns.set_collections({'edgecolor':'k'})
g.fig.get_edgecolor()[0].set_edge("k")
g.setp.get_collections()[0].set_edgecolor("k")
Run Code Online (Sandbox Code Playgroud)
谁能帮我吗?
另一个快速的问题是,除了whitegrid或darkgrid之外,是否可以更改网格颜色?Facecolor对我不起作用,因为它会为所有背景(包括刻度和标签区域)上色。我只想更改网格区域。谢谢!