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
2
votes
2 answers

Italics within plotmath expression cannot be rendered bold in ggplot

Based on previous posts I worked out how to use expression() to get a string within a string italicised while the rest of the string remains un-italicised. The problem is that element_text(face = "bold") does not work on strings inside expression().…
llewmills
  • 2,959
  • 3
  • 31
  • 58
2
votes
1 answer

Annotate ggplot plot with a multiline expression with objects?

I would like to make an annotation on my ggplot with two lines, sub- and superscripts, and references to objects. I've figured out that the annotate() function calls geom_text() which when parse = TRUE can use expressions from plotmath. If this is…
CephBirk
  • 6,422
  • 5
  • 56
  • 74
2
votes
1 answer

How to automate graph axis labeling with plotmath expressions?

I am trying to create multiple graphs with ggplot2 through using multiple instances of its plotting function and assign proper y-axis labels (with plotmath) to each function. Below is some code that demonstrates my failed solution. (mind the…
Nicholas Hayden
  • 473
  • 1
  • 3
  • 24
2
votes
1 answer

using glue::glue to write plotmath expressions like italic fontface or greek letters

Is there any way to use the glue package to write plotmath expressions? See an example below where I would like to use glue::glue to prepare an annotation for a plot. Or, actually, any other compact way to display the labels containing results would…
Indrajeet Patil
  • 4,673
  • 2
  • 20
  • 51
2
votes
0 answers

R tableGrob plot numbers in scientific notation in plotmath

I'd like to plot a table in R using tableGrob containing numbers which should display in scientific notation in math mode, such as 2.45x10⁵. I tried using format(x,scientific=TRUE) but it only displays as 2.45e+5. If I pass…
Martin
  • 59
  • 4
2
votes
1 answer

How to use parsing inside a gtable and retain trailing zeros

I want to add a table to my ggplot. Within that table I need to add a subscript to a few character values (for Winsorized means and standard deviations). This can be achieved when I specify parse = TRUE but then as a result I lose trailing zeros…
A Toll
  • 647
  • 7
  • 15
2
votes
1 answer

Merging expressions for plotting

I'm trying to merge two expressions made with bquote. For example: a = 1 b = 2 x1 = as.expression(bquote(paste("Something ", alpha, " = ", .(a), sep = ""))) x2 = as.expression(bquote(paste("Something else ", beta, " = ", .(b), sep = ""))) Is there…
user304347
  • 105
  • 1
  • 4
2
votes
1 answer

r bquote: remove the space before approximately equal plotmath symbol

This is almost what I want as a plot heading: plot(1:10) ylabs<-c("All","Native","Exotic") i=1 mtext(bquote("("*.(letters[i])*")"~.(ylabs[i])~"("%~~%italic("H'")*")"),side=3) But I don't want the space after "(" and before the approx. equal sign.…
asmith
  • 93
  • 1
  • 6
2
votes
1 answer

Italicizing the main word but not the subscripted word

I was wondering how to only make the main word d in my text() to appear in italic, but the subscripted word "unbiased" to remain as ordinary text? Please see my R code below the following picture. Here is my R code: plot(1:10, ty="n") text( 4,…
user7170429
2
votes
1 answer

Removing spaces in leading superscripts in ggplot2 axis titles and labels

Maybe i am not correct, but it appears to me that there is an undesired space in expressions beginning with a superscript: df <- data.frame(treatment=as.factor(c("A", "B")), value=c(1,2)) labels <- c(expression(""^14~CH[4]), …
nouse
  • 3,315
  • 2
  • 29
  • 56
2
votes
4 answers

R plotmath - how to display an apostrophe

I am trying to print an apostrophe for the column name below in a table using tableGrob "Kendall's~tau" The end result is that the whole label is italicized without the ~ and tau being interpreted: How do I correctly specify this? I don't think…
saladi
  • 3,103
  • 6
  • 36
  • 61
2
votes
1 answer

concatenate several math expressions in R

I know how to get my result if I use one long expression: expression(paste(M[O[2]], " (mg ", O[2], " ", h^-1, " ", kg^-1, ")")) But I tried to break this in chunks, so that the user could select a time and a mass unit (to add flexibility), and then…
Denis Chabot
  • 71
  • 1
  • 4
2
votes
0 answers

R plotmath - put "à" in expression

I have an axis title split over two lines using expression in the plotmath package (I am using expression as I need half of my title in plain text and half in bold). I need to include the character "à" in the title (it's in french), but the…
user2568648
  • 3,001
  • 8
  • 35
  • 52
2
votes
0 answers

R: bold numbers in plot annotation created by plotmath

I build graphics in which I use regular and bold font for titles and/or labels. They contain symbols, text and numbers which I combine using ?plotmath. I noticed that using bold within the expression changes only character strings to bold face, but…
SimonG
  • 4,701
  • 3
  • 20
  • 31
2
votes
0 answers

In R, how to horizontally align strings and math expressions appearing on separate rows in plot titles

I need to combine character strings and mathematical expressions to form the titles of plots. I need the strings and expressions to appear on separate rows. I achieve this by inserting "\n" symbols where needed in the character strings. However, the…
baixiwei
  • 1,009
  • 4
  • 20
  • 27