【问题标题】:Seaborn scatterplot overlaping points in y-tickSeaborn 散点图在 y-tick 中的重叠点
【发布时间】:2020-09-28 16:08:45
【问题描述】:

我有这个散点图:

我想让它看起来像下面的示例,但我在文档中找不到任何内容:

我的熊猫数据框在这里:

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

有什么想法吗?提前致谢。

【问题讨论】:

    标签: python pandas data-visualization seaborn scatter-plot


    【解决方案1】:

    如果你可以使用 seaborn,我认为类似 swarm plot

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

    【讨论】:

      猜你喜欢
      • 2020-10-10
      • 2020-12-04
      • 2018-03-17
      • 1970-01-01
      • 2021-01-22
      • 2022-01-18
      相关资源
      最近更新 更多