0

Is it even possible to pass a value in ggplot?

It is possible in a console using cat

v <- 8
ggplot(df, aes(x = Category, y = Fold_Change, color = Category)) +
labs(y= "RNA expression", x = cat("p-value = 0.08831", v) )

but what about graph?

1
  • 2
    cat says 'print to console'. Try using paste() here. Commented Nov 19, 2022 at 0:53

1 Answer 1

1

Use sprintf instead of cat, for example:

x = sprintf("%s %f %d", "p-value = ", 0.08831, v) )

I don't see any geom phrase in your example. I put some bogus data into a data.frame and used geom_point() to produce a plot for this example.

v <- 8
ggplot(df, aes(x = Category, y = Fold_Change, color = Category)) +
geom_point() + 
labs(y= "RNA expression", x = sprintf("%s %f %d", "p-value = ", 0.08831, v) )

example plot using sprintf

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.