[英]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.