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
4
votes
1 answer

White squares when using plotmath expressions

Whenever I try to use symbols in a plotmath expression in R, I get white squares. For example, when I run demo(plotmath), I get the following. Does anyone have an idea where the problem may lie? I am using R 3.4.1 in Rstudio on Mac OS X…
angryavian
  • 334
  • 3
  • 9
4
votes
1 answer

R: plotmath expression symbols not showing up in interaction plot

For some reason, my interaction plots don't seem to show the greek symbols (latex) in R markdown (using R studio). The code I am using is reproduced below. Why are the expression() functions not working? Any suggestions? with(ba_results,…
buzaku
  • 361
  • 1
  • 10
4
votes
1 answer

Italics and regular text in phylogeny tip labels in R

The following code will plot a phylogenetic tree with tip labels in italics and underscores replaced with spaces. library(ape) tr <- rtree(5, tip.label=c("a_b_x1", "b_c_2", "c_d_3y", "d_e_4", "e_f_5")) plot(tr) How can I combine regular text with…
nya
  • 2,138
  • 15
  • 29
4
votes
1 answer

R ggplot annotated with atop using three values and bgroup

Is there any way to annotate a ggplot with three lines one on top of the other, while keeping the text sizes the same across the three lines? I am almost there but the text sizes are different in the third line, it looks like the bgroup is only…
user971102
  • 3,005
  • 4
  • 30
  • 37
4
votes
1 answer

How can you use the atop function in expression()?

I need to add a line break but I am struggling with the atop function in expression(). The main is the part I would like to break into two lines. > plot (DAC~Chlo,data=brazilw, pch=15,col="red",cex=0.5, main=expression("Fig. 3.…
user3170629
  • 489
  • 3
  • 12
  • 21
4
votes
1 answer

Minus as an exponent in plotmath (in ggplot2 legend)

I'm trying to make a legend in a ggplot2 plot that contains a minus sign as an exponent (with no other characters in the exponent). However, I can't figure out the plotmath syntax. It seems like the following would work: expr1 <-…
Drew Steen
  • 16,045
  • 12
  • 62
  • 90
4
votes
1 answer

Write x̄ (meaning average) in legend and how to prevent linebreak?

Good day! I am not that familiar to R so I'd be glad to get a little help. Assume I have the following minimal example: test <- c(10,20,40,80,80) avg <- mean(test) avg <- format(avg,digits=2) plot(test, xlab="x", ylab="y", pch =…
Gnark
  • 4,080
  • 7
  • 33
  • 44
4
votes
1 answer

How to make the square root symbol in axes labels?

How can I make the square root symbol to appear ceiling an axis label in R?
user1730122
  • 51
  • 1
  • 1
  • 2
4
votes
2 answers

R mathematical annotations

I have a problem inserting a vertical line in a mathematical annotation. I have search through the annotation symbols without luck. I would like to put a mathematical annotation containing conditional probability sign (|) in the x-label of a plot.…
Sisse
  • 291
  • 1
  • 4
  • 14
3
votes
1 answer

Plot text containing "approximately equal to" in R

I am familiar with using expression() and bquote() when plotting special Tex like markup in textual base graphics in R. But how to do "approximately equal to" without having the parser throw an error. I am referring to ?plotmath when determining…
digitalmaps
  • 2,885
  • 3
  • 22
  • 28
3
votes
1 answer

How to include the results of a statistical test as a plotmath expression in ggplot2 facet

I'm looking to include the results of multiple statistical tests in a faceted ggplot chart. I've found lots of excellent examples (like this) on how to include something similar in a title or annotation, however, my interest lies in including it as…
vengefulsealion
  • 756
  • 11
  • 18
3
votes
1 answer

removing space between ggrepel label made using plotmath

I am creating a plot where I want to display labels using ggrepel. I am showing a minimal example below that illustrates how the label has two components separated by a comma - first related to the type of iris flower species and the second to the…
Indrajeet Patil
  • 4,673
  • 2
  • 20
  • 51
3
votes
2 answers

geom_text(), plotmath, and %

I want to add "R^2 = 70%" to my plot using geom_text() (where ^ indicates a superscript). Without the % sign, it's easy: my.data <- data.frame(x=1:5, y=1:5) p1 <- ggplot(my.data, aes(x=x, y=y)) + geom_point() p1 <- p1 + geom_text(x=2.5,…
user13424
  • 111
  • 1
  • 4
3
votes
2 answers

Display a fraction in a dynamically changing plot

I'm wondering how I can actually display a conditional calculation (see below) I'm using to obtain what I call GG in my R codes (see codes below)? Details: To be precise, I want to display in my plot that GG = G1 / G2 (displayed IF type = 1) and…
user7170429
3
votes
1 answer

Plotmath expression with mathematical operators in ggplot2

I am still struggling with correct labels of my plots. I managed to get this to work. df <-data.frame(a=seq(1,20),b=seq(1,20)) ggplot(df, aes(x = a, y = b)) + geom_point() + ylab(expression(paste(CH[4]~" formation rate"~"(",mu, mol,…
nouse
  • 3,315
  • 2
  • 29
  • 56