0

I'm tryin to create a text in box-plot to depict significance. I'd like to have "P" with italics and bold, that follows e.g., "= 1.23e-02" just using bold. I'm doing this inside a loop so that the significance should come from a value of an object. Trying to plot 8 figures into a pdf so in every plot the significance is different and thus is located in the object/vector. I've tried for example:

text(x=2.8, y=maxy+(((maxy-miny)/5)/5)*1.1, bolditalic(P)~bold("=")~bold(format(tp12[i])), cex = 2.8)

But for some reason this does not return the value of the object (significance) but rather just the string inside it. I've also tried number of different solutions with bquote and substitute with no success.

Any ideas how to get this combination to work?

MrFlick
  • 195,160
  • 17
  • 277
  • 295
  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input that can be used to test and verify possible solutions. You'll likely need some version of `bquote()` or `substitute()` to insert your value into your expression. It would be nice if you showed your "failed" solutions and say exactly what went wrong. It may be possible to easily fix them. – MrFlick Jul 14 '20 at 19:33

1 Answers1

0

Here is a simple reproducible example:

tp12 <- 1.23e-02
plot(1, 1)
text(1, 1, bquote(bolditalic(P)~bold("=")~bold(.(tp12[1]))), cex = 2.8, pos=3)

Bquote example

dcarlson
  • 10,936
  • 2
  • 15
  • 18