1

I am trying to write this bit of code in my ggplot block.

ggtitle(expression(atop(bold(paste0("Control rates Vs Mean yield for " , deparse(substitute(field)))), atop(italic("(Anova:TukeyHSD)"), "")))) 

It is either generating this error

Error in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y,  : 
  polygon edge not found 

and If it works, the plot will have title as it is: paste0("Control rates Vs Mean yield for ", deparse(substitute(field)))

How do I properly write this ggtitle?

1 Answer 1

2

May be we can use bquote

library(ggplot2)
field <- "Some Variable"
ggplot() +
    ggtitle(bquote(atop(bold(paste("Control rates Vs Mean yield for ", 
           .(field))), atop(italic("(Anova:TukeyHSD)")))))

enter image description here

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.