【发布时间】:2020-01-23 14:04:08
【问题描述】:
我有一张这样的表:(忽略“索引”和“D”列)
+-------+-----------------------+----------+----------+----------+
| Index | Type | Male | Female | D |
+-------+-----------------------+----------+----------+----------+
| 44 | Life struggles | 2.097324 | 3.681356 | 1.584032 |
| 2 | Writing notes | 2.677262 | 3.354730 | 0.677468 |
| 18 | Empathy | 3.528117 | 4.083051 | 0.554933 |
| 12 | Criminal damage | 2.926650 | 2.374150 | 0.552501 |
| 20 | Giving | 2.650367 | 3.196944 | 0.546577 |
| 21 | Compassion to animals | 3.666667 | 4.178268 | 0.511602 |
| 33 | Mood swings | 2.965937 | 3.451613 | 0.485676 |
| 10 | Funniness | 3.574572 | 3.104907 | 0.469665 |
| 38 | Children | 3.354523 | 3.805415 | 0.450891 |
| 47 | Small - big dogs | 3.221951 | 2.801695 | 0.420256 |
+-------+-----------------------+----------+----------+----------+
我知道如何在 R 中做到这一点,但在 python 中却不知道
我试过了:
sns.stripplot(data=df,y="Male",color="Blue")
sns.stripplot(data=df,y="Female",color="red")
但我不知道如何继续。有人有想法吗?
【问题讨论】:
-
看看python的plotnine库。它应该是ggplot的python实现
-
在
seaborn和matplotlib中操纵情节,您可以获得类似的效果。转到网页并开始尝试。否则,请尝试@luizgg 所说的plotnine。
标签: python matplotlib seaborn