0
說我有這樣的功能:GGPLOT2 - 在函數圖變化線寬
quad <- function(x)
{
return (x^2)
}
那我繪製使用ggplot
:
plot <- ggplot(data.frame(x=c(0,4)), aes(x = x)) +
stat_function(fun = quad)
到目前爲止,一切都很好,但該行是真的瘦了。因此,我添加一些特定的幾何形狀的線:
plot + geom_line(size=2)
但它返回此錯誤:
Error: geom_line requires the following missing aesthetics: y
如何操作線幾何在這種類型的圖表?
您需要'stat_function(fun = quad,size = 2)'。 –