带有 ggplot2 的辅助 x 轴

时间:2021-04-13 00:57:41

标签: r ggplot2 plot

我有以下数据框:

<头>
PhiSize CumVol
11.40 0.08
11.15 0.15
10.91 0.21
10.68 0.25 b
10.44 0.29 b
10.20 0.32 c
9.95 0.38 c

我想要绘制的是一个线图,它有一个像上面那样的辅助轴:

desired plot that has secondary axes

到目前为止我做到了

library(ggplot2)

df <- data.frame(read_csv("file")

ggplot(aes(x = PhiSize, y = CumVol, color = Group ), data = df) +
  geom_line() +
  scale_x_reverse()

并得到以下情节: enter image description here

但是当我添加最后一行时:

ggplot(aes(x = PhiSize, y = CumVol, color = Group ), data = df) +
  geom_line() +
  scale_x_reverse()+
  sec_axis(2^(-df$PhiSize),name = "new")

它抛出:

<块引用>

错误:无法将双向量转换为函数

我想得到一些帮助,拜托。

1 个答案:

答案 0 :(得分:2)

ClearCollect(colItemsToSave,Gallery3.AllItems);

enter image description here