Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 什么';在ggplot中,stat_函数的ggvis等价物是什么?_R_Ggvis - Fatal编程技术网

R 什么';在ggplot中,stat_函数的ggvis等价物是什么?

R 什么';在ggplot中,stat_函数的ggvis等价物是什么?,r,ggvis,R,Ggvis,我想用ggvis绘制一个函数-ggplot2中是否有类似于stat_函数的东西 例如: ggplot(data.frame(x=c(0,1)), aes(x=x)) + stat_function(fun=dbeta, args=list(shape1=2, shape2=10)) 我还没有找到与之相当的ggvis版本的ggplot2::stat_function()。但是,我使用了以下方法来解决使用ggvis::add_data()和ggvis::layer_path() 例如:以

我想用ggvis绘制一个函数-ggplot2中是否有类似于stat_函数的东西

例如:

ggplot(data.frame(x=c(0,1)), aes(x=x)) + 
    stat_function(fun=dbeta, args=list(shape1=2, shape2=10))

我还没有找到与之相当的
ggvis
版本的
ggplot2::stat_function()
。但是,我使用了以下方法来解决使用
ggvis::add_data()
ggvis::layer_path()

例如:以下内容将向
ggivs
散点图添加抛物线:

mtcars %>%
  ggvis() %>%
  layer_points(x = ~ wt, y = ~ mpg) %>% 
  add_data(data = data.frame(x = mtcars$wt, 
                             y = 49.931 - 13.380 * mtcars$wt + 1.171 * mtcars$wt^2)[order(mtcars$wt), ]) %>% 
  layer_paths(x = ~ x, y = ~ y, stroke := "red")