【发布时间】:2014-08-03 18:31:26
【问题描述】:
这个问题是关于 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_island 和nb_timepoints,我想用它们各自的值绘制所有other_timepoints。
我有以下代码:
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")
我想得到如下图所示的东西,我该如何实现?
附言。我附加了一个文件,显示了我想要实现的大致目标(只有我想要网格、标签、轴等)
【问题讨论】:
-
代码正常,添加分面后忘记打印了。
标签: python r ggplot2 rpy2 facet