小编Luc*_*fer的帖子

如何强制splinefun值为正?

我使用来自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)

图像在此链接中

r spline ggplot2

5
推荐指数
1
解决办法
351
查看次数

在 R 中,如何在绘图中绘制多个 3D 曲面时添加附加轴?

就像示例数据一样: https: //plot.ly/r/3d-surface-plots/

我想让每个表面都有自己的轴,并且仍然位于同一个图中。

我有 ps 示例生成的图来显示我的意思,上面的一个是我所拥有的,下面的一个是我想要的:

这就是我得到的: 在此输入图像描述

这就是我要的: 在此输入图像描述

有人可以告诉我该怎么做吗?

axis r plotly

5
推荐指数
0
解决办法
841
查看次数

标签 统计

r ×2

axis ×1

ggplot2 ×1

plotly ×1

spline ×1