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
0 answers

bquote, parsing, expression to get multiple lines labels in ggplot with greek letters and variables as subscripts

Let's say I have paste0("Year = ",index,"\nN = ",length((dfGBD %>% filter(year==index))[[vbl]]), " Bandwidth = ",round(stats::bw.nrd(log((dfGBD %>% filter(year == index))[[vbl]])),2), …
iago
  • 2,990
  • 4
  • 21
  • 27
1
vote
1 answer

Use dataframe variable names in plot titles

I have a dataframe with several variables that I wish to label and then use in several ggplots. I have applied labels using the labeller package with the following code. library(tidyverse) library(labeller) library(ggpubr) example.df <-…
jaydoc
  • 79
  • 1
  • 7
1
vote
2 answers

including conditional elements in plotmath expression for ggplot2 subtitle

I am trying to write a custom function where I want to display an effect size estimate and its confidence intervals in ggplot2 plot subtitle. I am using plotmath to properly display Greek letters and other mathematical symbols. This is what the two…
Indrajeet Patil
  • 4,673
  • 2
  • 20
  • 51
1
vote
1 answer

In R, how can a string function argument be expanded to mathematical symbols using plotmath?

Here is an example: PMEx <- function(t) { y <- (1:10)^2 plot(1:10,y,type="l") text(2,90,label="This is NOT what I want -->",adj=0) text(2,80,label="This IS what I want -->",adj=0) text(2,70,label="This is NOT what I want…
GWB
  • 11
  • 2
1
vote
1 answer

creating a new column containing plotmath expression using `dplyr::case_when`

I would like to create a new column containing plotmath expressions that I later plan to use somewhere else in the analysis pipeline. Here is a minimal example along with I tried. For example, here I am trying to create a new column called label…
Indrajeet Patil
  • 4,673
  • 2
  • 20
  • 51
1
vote
0 answers

In R plots, how to have symbol for the set of real numbers with font similar to LaTeX's \mathbb?

Here is what I am trying to achieve. When designing a plot in R-project, I would like to include in the plot's legend/axes the "R" symbol for the set of real numbers with font similar to that of LaTeX's \mathbb command (i.e. the stylized way to…
S08
  • 51
  • 6
1
vote
1 answer

How to make a multi-line x axis title with mathematical expressions in ggplot2

xlab(expression(paste("CO"^"2", " concentration", "\n Lolium perenne"))) This is my current coding. With my xlab I want to have CO^2 concentration on one line, and then "Lolium perenne" beneath that but it also needs to be in italics. Currently…
1
vote
1 answer

How to escape predefined symbols e.g. % with plotmath?

I'm using the plotmath support while adding annotations to my plot i.e. using the parse=TRUE argument. Reviewing the plotmath documentation here it is not clear how to escape predefined symbols e.g. % label <-…
SkyWalker
  • 13,729
  • 18
  • 91
  • 187
1
vote
1 answer

build plotmath expressions and strings programmatically using bquote or other commands

I would like to build some plotmath expressions and some string programmatically. The expressions and strings (in other words, the desired output) are k[xy[2]] k[xy[5]] k[xy[7]] k[xy[9]] k[xy[11]] k[xy[13]] K[xx[2]] K[xx[5]] K[xx[7]] K[xx[9]] …
DeltaIV
  • 4,773
  • 12
  • 39
  • 86
1
vote
1 answer

R: Drawing a textGrob fails with mysterious error

I have four different kinds of graphic, each converted to a grob with apparent success. I am trying to combine them into a single image with grid.arrange(). One of the four -- I would say the simplest of the four -- produces an error, even without…
andrewH
  • 2,281
  • 2
  • 22
  • 32
1
vote
1 answer

Adding greek characters with variables to axis title

I have two vectors alpha <- c(1,2,3), beta <- c(4,5,6). I have three plots and each of them is using diferent alpha and beta (etc. first plot contains alpha[1] and beta[1]) Now I would like to add axis title to each graph like: "alpha = 1, beta = 4"…
Marek Čačko
  • 980
  • 2
  • 21
  • 31
1
vote
1 answer

Alternative to Vector of Plotmath Expressions

I'm trying to label an axis at every 3rd tick with a 10^n value, formatted as a superscript. I'm using grid graphics. I'm doing something bassackwards. Here's a MWE (or I see there is some movement to call it a…
Bryan Hanson
  • 6,055
  • 4
  • 41
  • 78
1
vote
1 answer

Plotmath: concatenating (joining) a greek character to a roman character

I'm trying to make a label which starts out with 'micrograms' except that it should be abbreviated. I tried this: plot(1, main = expression(mu~g~Toxin/gram~Fresh~Weight)) but it is rendered with a gap between mu and g which I don't want. I…
Bryan Hanson
  • 6,055
  • 4
  • 41
  • 78
1
vote
0 answers

geom_text with " %up% crashing r

any ideas on why this is crashing r? ideally i'd have no text in front of the up arrow, a space would be acceptable, but both segfault r. ggplot2 is version 1.0.1. library(ggplot2) ## Use suppressPackageStartupMessages to eliminate package startup…
keithpjolley
  • 2,089
  • 1
  • 17
  • 20
1
vote
1 answer

adjusting line height of a multi-line expression() statement with grid or lattice graphics

I have a lattice figure that contains a multi-line expression() statement. I want to fine–tune the vertical space between the lines of this statement. Is there a way to do this? Here is code that demonstrates the…
user697473
  • 2,165
  • 1
  • 20
  • 47