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
1
vote
1 answer

In R, how to control spacing within mathematical annotations in plots

I'm trying to insert mathematical expressions into the titles of plots. I need to control the spacing within the mathematical expressions. For example, I'd like to show the expression "64/8 / 8" except with division signs instead of slashes. I need…
baixiwei
  • 1,009
  • 4
  • 20
  • 27
1
vote
1 answer

Substitute plotmath character string into expression

I couldn't find the answer to this in the multitude of similar, but not quite the same questions on the site. Let's say I have a character string in a variable, which is a direct representation of the plotmath expression I want to use, e.g. "R^2".…
Simon O'Hanlon
  • 58,647
  • 14
  • 142
  • 184
1
vote
1 answer

Substitute not displaying text on plots

I just recently learnt about plotmath and its ability to put mathematical expression in text on plots. However I'm encountering some strange behaviour where the substitute function does not render any text. Here's a simple case that should work…
Scott Ritchie
  • 10,293
  • 3
  • 28
  • 64
1
vote
1 answer

title and text formatting in r - use simultaneously variables and superscript

I would like to use simultaneously the value of a variable and math formatting in the title of a classic (no ggplot2) figure in R. I found a solution to have the content of the variable in the title, but not the superscript. number <-…
fstevens
  • 1,287
  • 1
  • 17
  • 28
1
vote
1 answer

Intervals in axis labels using plotmath symbols

I want to use plotmath symbols in R to add an interval to the X axis of a plot, such as 3<=X<=4. I know you can do something like: x=1:10 x1=3 x2=4 plot(x, xlab=substitute(a <= X *""~ X <= b, list(a=x1,b=x2))) But I cannot remove the second X as…
jcredberry
  • 97
  • 7
1
vote
1 answer

Using subscript and line break at the same time in plot titles in R

I wish to include a subscript and a title running into two lines at the same time but am not getting desired result with following commands: base<-'B1' compare<-'A1' plot (1, 1, main = bquote('Annual mean' ~CO[2] ~'Flux Difference: \n' ~.(compare)~…
Munish
  • 667
  • 3
  • 13
  • 34
0
votes
1 answer

How do I incorportate both an italicised letter and a new line in labels when using geom_text() in ggplot2?

I wish to create a geom_tile plot which summarises the output of a particular model I've been working with. Specifically, in each tile I want to display the beta coefficient with the p-value on a new line. However I would like to use an italicised…
L.D.
  • 51
  • 3
0
votes
2 answers

Creating a new column/vector of expressions in R

I have an example dataset: test <- data.frame(x = c("BG10", "C1456", "DXT6"), y = c("293S", "124F", "124F")) x y 1 BG10 293S 2 C1456 124F 3 DXT6 124F where I am ultimately trying to combine columns x and y, and then label the new column…
vizidea
  • 153
  • 7
0
votes
1 answer

Axis title containing texts with exponents

I'm using ggplot2 to plot a chart. I want to add an exponent to a text within the Y-axis title, so it would look like this: Energy (kcal ∙ mol-1) I usually write the axis title text inside labs () and its aesthetic inside theme (axis.title.y =…
ginn
  • 87
  • 5
0
votes
0 answers

Expressions not displaying some math text in R / Rstudio

Multiplication and division plotmath show up as empty boxes in the Rstudio IDE: plot(1,2,main=expression('1'%*%10^-03)) Yet, if this is printed to a pdf, it is…
Dylan_Gomes
  • 2,066
  • 14
  • 29
0
votes
1 answer

Parse an annotation across multiple lines in ggplot

Closest I've come is here: Annotate ggplot plot with a multiline expression with objects? but I cannot seem to get the solution working. I cannot use the ggpmisc package because I am forcing the regression through the origin. Here's some example…
dandrews
  • 967
  • 5
  • 18
0
votes
1 answer

How do I use plotmath to create subscript/superscript in a string from a list?

I am creating multiple plots with parameter names in the ggtitle. Some of these have subscripts, superscripts or other plotmath characters. My parameters are stored in a param-list and are presented as strings in my ggplot function that I am looping…
0
votes
1 answer

atop with multiple linebreaks and subscripts in geom_label

I have a dataframe for which I am plotting data using ggplot. My objective is to add an annotation using geom_label, with words that contain subscripts and linebreaks. In particular two linebreaks. Here is a reproducible example: ###DATA### data_df…
CafféSospeso
  • 1,101
  • 3
  • 11
  • 28
0
votes
1 answer

Why is ggplot annotation created with expression and bquote in bold font?

Using ggplot2 I need a multi-line annotation that incorporates variable values, commas, a Greek letter, and a superscript. I played with a lot of different ideas I found in this forum for doing this but nothing I tried worked the way I wanted. I…
Fleetboat
  • 189
  • 7
0
votes
1 answer

How to put plotmath labels in ggplot facets

We often want individual regression equations in ggplot facets. The best way to do this is build the labels in a dataframe and then add them manually. But what if the labels contain plotmath, e.g., superscripts?
Simon Woodward
  • 1,946
  • 1
  • 16
  • 24