使用ggplot进行更有效的绘图

时间:2018-10-29 20:43:39

标签: r ggplot2

我有一个数据集df,如下所示:

# A tibble: 35,809,246 x 5
    time  conc          t factor     x
   <int> <dbl>      <dbl> <chr>  <dbl>
 1    25  555. 0          1       174.
 2    25  555. 0.00000488 1       174.
 3    25  555. 0.00000977 1       174.
 4    25  555. 0.0000146  1       174.
 5    25  555. 0.0000195  1       174.
 6    25  555. 0.0000244  1       174.
 7    25  555. 0.0000293  1       174.
 8    25  555. 0.0000342  1       174.
 9    25  555. 0.0000391  1       174.
10    25  555. 0.0000469  1       174.
# ... with 35,809,236 more rows

time100唯一值连续。 factor22水平的一个因素。我想做下面的情节:

ggplot(df, aes(x = t)) +
  geom_line(aes(y = x, color = time)) +
  facet_wrap(~factor, ncol = 2, scales = "free_y",
             labeller = labeller(factor = factorNames)) +
  theme(axis.text = element_text(size = rel(0.5)))

但是,绘图需要30多分钟,并且保存时间也差不多。因此,就时间成本而言,编辑代码并重做绘图是非常禁止的。有什么方法可以使绘图更加有效?预先感谢。

0 个答案:

没有答案