Reputation: 6842
Say I have function like:
quad <- function(x)
{
return (x^2)
}
That I plot using ggplot
:
plot <- ggplot(data.frame(x=c(0,4)), aes(x = x)) +
stat_function(fun = quad)
So far, so good, but the line is really thin. I thus add some specific geometry to the line:
plot + geom_line(size=2)
But it returns this error:
Error: geom_line requires the following missing aesthetics: y
How can I manipulate line geometry in this type of graphs?
Upvotes: 1
Views: 2916
Reputation: 6842
After playing around a while I found out that an argument named size
can be passed into stat_function
. It has the same effect as gem_line
:
plot <- ggplot(data.frame(x=c(0,4)), aes(x = x)) +
stat_function(fun = quad, size=1.5)
Upvotes: 2