我使用来自splinefun的值生成了一个ggplot,但是在0附近的区域内值不应该为负,如下图所示.
我想知道当它们为负数时如何强制splinefun中的值为0?谢谢!
sigma <- c(0,1,2,3,4,5,6,7,8,9,10,11,12)
sigma <- matrix(sigma,ncol=1)
myFunc_sig <- function(sigma){
exp(-2/sigma^2)
}
output_sigma <- apply(sigma, 1, myFunc_sig)
spl_fun <- splinefun(sigma, output_sigma)
ggplot(data.frame(x = sigma, y = output_sigma), aes(x, y))+
stat_function(fun = spl_fun, color = "orange")+
scale_x_continuous(expand = c(0, 0)) +
scale_y_continuous(expand = c(0, 0))
Run Code Online (Sandbox Code Playgroud)

就像示例数据一样: https: //plot.ly/r/3d-surface-plots/
我想让每个表面都有自己的轴,并且仍然位于同一个图中。
我有 ps 示例生成的图来显示我的意思,上面的一个是我所拥有的,下面的一个是我想要的:
有人可以告诉我该怎么做吗?