相关疑难解决方法(0)

在R中的数据点上绘制函数

有没有办法使用ggplot在数据之上叠加数学函数?

## add ggplot2
library(ggplot2)

# function
eq = function(x){x*x}

# Data                     
x = (1:50)     
y = eq(x)                                                               

# Make plot object    
p = qplot(    
x, y,   
xlab = "X-axis", 
ylab = "Y-axis",
) 

# Plot Equation     
c = curve(eq)  

# Combine data and function
p + c #?
Run Code Online (Sandbox Code Playgroud)

在这种情况下,我的数据是使用函数生成的,但我想了解如何使用curve()ggplot.

statistics plot r function ggplot2

9
推荐指数
1
解决办法
2万
查看次数

标签 统计

function ×1

ggplot2 ×1

plot ×1

r ×1

statistics ×1