seaborn的swarmplot可以调整点的marker形状吗?
•浏览 1
Can the swarmplot of seaborn adjust the marker shape of points?
我使用 seaborn 中的 swarmplot 函数来绘制类别散点图。但我在每个类别中有两种类型的点。所以我希望可以将不同类型的点设置为不同的标记。
seaborn的swarmplot可以调整点的标记形状吗?或者我可以使用其他工具
我只发现swarmplot的文档中可以调整参数标记的大小。我尝试使用色调。但是当我使用色调时,所有类别都代表相同的颜色。那不是我的主意。
3.
# plot the manhattan map
snsplt =sns.swarmplot(x=scale,y=distance,marker='o')
plt.tick_params(labelsize=12)
# plot the significant line
bin = np.arange(-0.2,5.2,0.2)
y = np.full((len(bin),),distance[p_minsignIndex])
snsplt = sns.lineplot(x=bin,y=y)
plt.show()
import seaborn as sns
import numpy as np
tips['bigness'] = np.where(tips['total_bill']>15, 'big', 'small')
sns.swarmplot(x="day", y="total_bill", hue="bigness", data=tips, palette="Paired", hue_order=["small","big"])
图片是我的草稿。
我希望线条上方的圆圈是实心圆圈,而线条下方的圆圈是空心圆圈。
鉴于您展示的情节,您似乎有两个类别同时发生:
1) 沿轴的位置表示一个类别——我称之为cat1;和,
2) 每个类别中的变化,这就是您希望通过标记显示的内容——我称之为 cat2.
到目前为止,将这两个类别一起显示的最简单方法是使用 seaborn 提供的工具来执行此操作。具体来说,在您的绘图中,您以两种不同的方式识别 cat1:首先通过其沿 x 轴的位置,其次通过颜色。所以想法是使用 cat1 的位置和 cat2 的颜色。此外,您在下面的评论中提到您想使用标记来显示统计显着性,所以我选择了一个做得很好的调色板。这是从 seaborn 文档中获取的示例,但经过修改以显示显着性阈值(根据您的要求):
# plot the manhattan map
snsplt =sns.swarmplot(x=scale,y=distance,marker='o')
plt.tick_params(labelsize=12)
# plot the significant line
bin = np.arange(-0.2,5.2,0.2)
y = np.full((len(bin),),distance[p_minsignIndex])
snsplt = sns.lineplot(x=bin,y=y)
plt.show()
import seaborn as sns
import numpy as np
tips['bigness'] = np.where(tips['total_bill']>15, 'big', 'small')
sns.swarmplot(x="day", y="total_bill", hue="bigness", data=tips, palette="Paired", hue_order=["small","big"])