在python中的多个数值变量上绘制类别变量

时间:2019-12-12 13:38:00

标签: python plot seaborn scatter-plot

我需要在多个数值变量上绘制一个类别变量。

我的DataFrame看起来像这样:

                          party  media_user  business_user      POLI      mass
0                       Party_a    0.513999       0.404201  0.696948  0.573476
1                       Party_b    0.437972       0.306167  0.432377  0.433618
2                       Party_c    0.519350       0.367439  0.704318  0.576708
3                       Party_d    0.412027       0.253227  0.353561  0.392207
4                       Party_e    0.479891       0.380711  0.683606  0.551105

我想为不同的变量使用不同的颜色绘制散点图;例如。每个参与方每个[media_user,business_user,POLI,mass]都有一个不同颜色的地块。

所以像这样,只是散布而不是条形:

bar chart

我最近来的就是这个

sns.catplot(x="party", y="media_user", jitter=False, data=sns_df, height = 4, aspect = 5);

生产:

cat_scat_plot

1 个答案:

答案 0 :(得分:1)

通过弄乱其他一些图形,我发现只需添加linestyle = ''就可以删除线并添加标记。希望这可以对其他人有所帮助!

sim_df.plot(figsize = (15,5), linestyle = '', marker = 'o')

enter image description here