简体   繁体   中英

Can the swarmplot of seaborn adjust the marker shape of points?

  1. I used the swarmplot function in seaborn to plot the category scatter plot. But I have two types of points in each category. So I wish can set different types of points into different markers. Can the swarmplot of seaborn adjust the marker shape of points? Or I can use other tools

  2. I only found the parameter markers size can be adjusted in the document of the swarmplot. And I tried to use hue. But when I use hue, all categories represent same color. That is not my idea.

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()

The image is my draft.

I wish the circles above the line are filled circles and the circles below the line are hollow circles.

Given the plots you show, it seems that you have two categories happening at the same time:
1) the position along the axis indicates one category -- I'll call this cat1 ; and,
2) variation within each category and this is what you want to show by the marker -- I'll call this cat2 .

By far, the easiest ways to show these two categories together is to use the tools given to you by seaborn to do this. Specifically, in your plots, you are identifying cat1 in two different ways: first by its position along the x-axis, and second by the color. So the idea is to use the position for cat1 and the color for cat2 . Also, you mention in the comments below that you want to use the markers to show a statistical significance, so I chose a palette that does that well. Here's an example taken from the seaborn docs, but modified to show a significance threshold (as you requested):

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"])

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM