Questions tagged [plotmath]

plotmath provides mathematical expression plotting in the R language.

Arguments to the text plotting functions in (text, mtext, axis, legend) accept both character and expression arguments. Character values are drawn to the plot as-is, while expressions are evaluated according plotmath rules. These rules differ from those for typical R expressions (see documentation).

169 questions
3
votes
3 answers

Displaying values from a character vector as italic labels in boxplot in R

I want to use a character vector for boxplot names, how can I get these to be displayed as italic? # get some data x <- rnorm(1000) # I want to get this: labels <- c(expression(italic("One"), italic("Two"))) labels boxplot(split(x, cut(x,breaks =…
CCID
  • 1,368
  • 5
  • 19
  • 35
3
votes
2 answers

How to add >-sign to expression in R?

I'd like to add a "greater than"-sign to an axis label. The text shown should be cumulated frequency p(>p[f])) I tried (amongst others): title(mgp=c(2.50, 1, 0), cex.lab=1.25, xlab = expression("cumulated frequency" ~ p(>p[f]))) # xlab But none of…
R_User
  • 10,682
  • 25
  • 79
  • 120
3
votes
1 answer

Better solution regarding annotation in ggplot?

I have the following code standard_text = "(%)" plotmath_text <- "I^2" g <- ggplot(data=data.frame(x=0,y=0))+geom_point(aes(x=x,y=y)) g+ annotate("text", x = 4.3, y = 6.97, label =standard_text)+ annotate("text",x = 4, y = 7, cex = 7,…
Nick
  • 77
  • 1
  • 4
3
votes
2 answers

how to use expression in in names.arg function

I have several carbon compounds in my bar graph but I need to subscript the numbers associated with each one, e.g. C*12*-C*16*, C*17*-C*25*,C*26*-C*32*,C*33*-C*37*. I am trying to use the expression function but it is not going well with the…
user3170629
  • 489
  • 3
  • 12
  • 21
3
votes
1 answer

Strings & Expressions in Plot Titles, Labels etc

I am trying to paste together user a user provided string and a fixed string in a plot title. A simple case that works, of course: userTitle <- "user title" # Example 1 fullTitle <- paste(userTitle, ": Results", sep = "") plot(1:10, main =…
Bryan Hanson
  • 6,055
  • 4
  • 41
  • 78
3
votes
1 answer

R Base Graphic: Annotate with logical symbols (and/or)

I would like to add the logical symbols and (∧) and or (∨) to a base graph in R. I figured that the way to go will probably be using an expression, but I can't figure out how, as their unicode codes \u2227 and \u2228 are not working. Perhaps because…
Henrik
  • 14,202
  • 10
  • 68
  • 91
3
votes
1 answer

How to STOP superscripting in an R plot axis label when using grid

I have used 'grid' to put together some plots I made in ggplot, and then I used 'grid.text' to give these plots the same y-axis label. I eventually figured out how to get a superscript in there for -2, but I do not want the parenthesis following…
Nazer
  • 3,654
  • 8
  • 33
  • 47
3
votes
2 answers

R: legend expression how to add comma between two values and how to supress scientific notation

I'm trying to format the legend in my plot, but I have to use expression() because of greek and superscripts. However, when I want to display r^2 = 0.45, P<0.0001, I get r^2 = 0.45 P<1e-04, when I type in…
crazian
  • 649
  • 4
  • 12
  • 24
3
votes
2 answers

using expressions (plotmath) on axis in r

This works fine data = c(1,3,2) max_y <- max(data) plot_colors <- c("blue") plot(data, type="l", col=plot_colors[1], ylim=c(0,max_y), axes=FALSE, xlab=expression(e[3])) axis(1, at=c(1,2,3), lab=expression(e[1],e[2],e[3]) ) But I would like to…
dziadgba
  • 135
  • 7
2
votes
1 answer

plotmath symbol displaying as a white rectangle

I'm running code on a new computer (Windows 10 Enterprise OS) with R 4.2.2. I'm running code I've been using for years, but on the new system, my plot shows little white rectangles instead of plotmath symbols. I've seen several people running into…
user2602640
  • 640
  • 6
  • 21
2
votes
1 answer

Inserting math symbols in legends of R plots

I am using survminer to produce a survival plot with 2 survival curves, one for patients who had received 4 Packed Red Blood Cells (PRBC) units during surgery and one for patients who received more than 4 PRBC units. Unfortunately I have not been…
user156625
  • 33
  • 4
2
votes
1 answer

Bolding Greek letters in R

I want to add a greek letter to my the margin of a figure, and I used the line of code below: mtext(side=2,line=6,text=expression(paste(beta,"-Actin Normalized")),font=2,cex=2) However, when I use the mtext function in combination with greek…
Aaron
  • 21
  • 1
  • 2
2
votes
2 answers

How to place an expression on top of another expression using plotmath

If I want to generate a multi-line expression I can do: over = 'OVER' below = 'BELOW' x_lab_title = bquote(atop(.(over), .(below))) ggplot(data.frame()) + xlab(x_lab_title) However, I would like to make over and below expressions on their own,…
krassowski
  • 13,598
  • 4
  • 60
  • 92
2
votes
4 answers

using `plotmath` to display combination of subscript and `[ ]`

I want to create a plot where I want to display a mean value and confidence intervals for this mean value. To do so, I am using plotmath. Here is something I have done that works- library(ggplot2) ggplot(mtcars, aes(as.factor(cyl), wt)) +…
Indrajeet Patil
  • 4,673
  • 2
  • 20
  • 51
2
votes
0 answers

Irregular bolding in plotmath expression in ggplot2

I want to be able to pass an argument from a function into a label on a ggplot graph and for that label to be in bold. Unicode won't work because many unicode symbols don't render to pdf. Plotmath expressions can be split apart in paste(), which…
llewmills
  • 2,959
  • 3
  • 31
  • 58