[英]R ggplot2 - Plot multiple functions in one plot with different x-axis ranges
我想在一个图中绘制不同的数学函数,将其中一些限制为x值的不同范围。 代码是:
# Different functions
stereographic <- function(theta,f=1) {
2*f*tan(theta/2.0)
}
equidistant <- function(theta,f=1) {
f*theta
}
equisolidangle <- function(theta,f=1) {
2*f*sin(theta/2.0)
}
orthographic <- function(theta,f=1) {
f*sin(theta)
}
# Plot
p <- ggplot(data = data.frame(x = c(0,pi)), mapping = aes(x = x))
p <- p +
stat_function(fun=stereographic,aes(colour="Stereografisch")) +
stat_function(fun=equidistant,aes(colour="Äquidistant")) +
stat_function(fun=equisolidangle,aes(colour="Flächentreu")) +
ylim(0,3)
print(p)
现在,我想在x轴范围[0,pi / 2]中添加另一个函数,但是找不到有效的方法。 我总是得到类似ggplot2 doesn't know how to deal with data of class uneval
东西, ggplot2 doesn't know how to deal with data of class uneval
。 是否可以将stat_function
限制在新的x轴范围内,或者还有另一种好的方法?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.