刻面条形图rpy/ggplot2无法工作,只能继续

2024-05-16 23:21:07 发布

您现在位置:Python中文网/ 问答频道 /正文

这个问题是关于rpy2中的ggplot2的,但是如果对你来说比较容易的话,我会接受R中的答案。以后我很乐意翻译这个解决方案。你知道吗

我有一个如下所示的rpy2数据帧(完整文件here):

    times_seen nb_timepoints main_island other_timepoint

1            0             2           0               0
2          346             2           0               3
3          572             2           0               6
4          210             2           0               9
5          182             2           0              12
6          186             2           0              18
7          212             2           0              21
8          346             2           3               0
...

对于每个main_islandnb_timepoints,我想用它们各自的值来绘制所有的other_timepoint。你知道吗

我有以下代码:

import rpy2.robjects.lib.ggplot2 as ggplot2
import rpy2.robjects as ro

p = ggplot2.ggplot(rpy2_df) + ggplot2.aes_string(y='times_seen', x='other_timepoint') + ggplot2.geom_bar(stat="identity")

我想得到的东西,如下图所示,我如何实现这一点?你知道吗

另外,我已经附加了一个文件,显示了大约我想实现(只是我想要网格,标签,轴等)

enter image description here


Tags: 文件importmainasotherseentimesnb