1

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?

1
  • You need stat_function(fun = quad, size = 2). Commented Oct 29, 2017 at 8:33

1 Answer 1

2

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)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.