y-tick 中的 Seaborn 散点图重叠点
Seaborn scatterplot overlaping points in y-tick
我有这个散点图:
我想让它看起来像下面的示例,但我在文档中找不到任何内容:
我的 pandas 数据框在这里:
Year,UserStudy_NumParticipants
2019,40
2019,30
2018,10
2018,2
2018,623
2018,10
2018,43
2018,44
2018,36
2018,60
2018,22
2018,129
2017,20
2017,16
2017,18
2017,20
2017,30
2017,31
2016,40
2016,250
2016,28
2016,40
2016,39
2016,171
2015,40
2015,2
2015,150
2015,30
2015,45
2015,225
2015,50
2015,5
有什么想法吗?提前致谢。
我想是这样的swarm plot如果你可以使用 seaborn。
import pandas as pd
d = {'Year':[2019, 2019, 2018, 2018, 2018, 2018, 2018, 2018, 2018, 2018, 2018, 2018, 2017, 2017, 2017, 2017, 2017, 2017, 2016, 2016, 2016, 2016, 2016, 2016, 2015, 2015, 2015, 2015, 2015, 2015, 2015, 2015], 'UserStudy_NumParticipants': [40 ,30 ,10 ,2 ,623 ,10 ,43 ,44 ,36 ,60 ,22 ,129 ,20 ,16 ,18 ,20 ,30 ,31 ,40 ,250 ,28 ,40 ,39 ,171 ,40 ,2 ,150 ,30 ,45 ,225 ,50 ,5]}
df = pd.DataFrame(data=d)
import seaborn as sns
import matplotlib.pyplot as plt
plt.figure(figsize=(10,10))
sns.set(style="whitegrid")
ax = sns.swarmplot(x="UserStudy_NumParticipants", y="Year", data=df,size=10, orient='h')
我有这个散点图:
我想让它看起来像下面的示例,但我在文档中找不到任何内容:
我的 pandas 数据框在这里:
Year,UserStudy_NumParticipants
2019,40
2019,30
2018,10
2018,2
2018,623
2018,10
2018,43
2018,44
2018,36
2018,60
2018,22
2018,129
2017,20
2017,16
2017,18
2017,20
2017,30
2017,31
2016,40
2016,250
2016,28
2016,40
2016,39
2016,171
2015,40
2015,2
2015,150
2015,30
2015,45
2015,225
2015,50
2015,5
有什么想法吗?提前致谢。
我想是这样的swarm plot如果你可以使用 seaborn。
import pandas as pd
d = {'Year':[2019, 2019, 2018, 2018, 2018, 2018, 2018, 2018, 2018, 2018, 2018, 2018, 2017, 2017, 2017, 2017, 2017, 2017, 2016, 2016, 2016, 2016, 2016, 2016, 2015, 2015, 2015, 2015, 2015, 2015, 2015, 2015], 'UserStudy_NumParticipants': [40 ,30 ,10 ,2 ,623 ,10 ,43 ,44 ,36 ,60 ,22 ,129 ,20 ,16 ,18 ,20 ,30 ,31 ,40 ,250 ,28 ,40 ,39 ,171 ,40 ,2 ,150 ,30 ,45 ,225 ,50 ,5]}
df = pd.DataFrame(data=d)
import seaborn as sns
import matplotlib.pyplot as plt
plt.figure(figsize=(10,10))
sns.set(style="whitegrid")
ax = sns.swarmplot(x="UserStudy_NumParticipants", y="Year", data=df,size=10, orient='h')