[英]Secondary x-axis with ggplot2
I have the following data frame:我有以下数据框:
PhiSize![]() |
CumVol![]() |
Group![]() |
---|---|---|
11.40 ![]() |
0.08 ![]() |
a![]() |
11.15 ![]() |
0.15 ![]() |
a![]() |
10.91 ![]() |
0.21 ![]() |
a![]() |
10.68 ![]() |
0.25 ![]() |
b ![]() |
10.44 ![]() |
0.29 ![]() |
b ![]() |
10.20 ![]() |
0.32 ![]() |
c ![]() |
9.95 ![]() |
0.38 ![]() |
c ![]() |
What i want to plot is a line-plot that has a secondary axis like the one above:我想要 plot 是一个线图,它有一个像上面那样的辅助轴:
So far i did到目前为止我做到了
library(ggplot2)
df <- data.frame(read_csv("file")
ggplot(aes(x = PhiSize, y = CumVol, color = Group ), data = df) +
geom_line() +
scale_x_reverse()
And got the following plot:并得到以下 plot:
But when i add the last line:但是当我添加最后一行时:
ggplot(aes(x = PhiSize, y = CumVol, color = Group ), data = df) +
geom_line() +
scale_x_reverse()+
sec_axis(2^(-df$PhiSize),name = "new")
It throws:它抛出:
Error: Can't convert a double vector to function
错误:无法将双向量转换为 function
I would like to get some help, please.我想得到一些帮助,拜托。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.