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

Superscripting in ggplot2 using plotmath

I'm trying to get a superscript for units of my y-axis using plotmath expressions referenced in several posts. I've looked through threads on using expression and also here, but it just isn't working for me. Here's what I have so…
KVininska
  • 107
  • 1
  • 6
7
votes
1 answer

Unicode character with subscript

I want to add a Unicode character which has two letters as subscripts to my plot legend in R. The character is an r with an accent breve (ř) and the two letters are i and j. I already looked at this question: Unicode character with superscript and…
Nadja Simons
  • 1,196
  • 1
  • 7
  • 10
7
votes
1 answer

Adjusting font.lab to get bold in plotmath expression?

with the following code, xlab will be bold but ylab not. could you please help me pdf() par(font.axis=2, font.lab=2, cex.lab=1.2, cex.axis=1.2, cex.sub=1.2, mfrow=c(2,2), mar = c(5,6,3,1) + 0.1) hist(ADAM, axes=F, main="", ylim=c(0,1000000),…
EpiMan
  • 839
  • 3
  • 11
  • 26
7
votes
3 answers

Plot main title in two lines

I would like to have the title for the plot in two lines, but this does not work, why? and how can I make it work? CVal<-1 SumEpsVal<-2 plot(1:10, main=bquote(paste("C=", .(CVal), " \n ", sum(xi), "=", .(SumEpsVal) ))) This here works: plot(1:10,…
Giuseppe
  • 786
  • 1
  • 7
  • 18
7
votes
2 answers

Combining `expression()` with `\n`

I have a ggplot where I have used expression(phantom(x) >=80) in the label text to get a proper greater-than-or-equal symbol. However I also need to have (N=...) immediately underneath: require(ggplot2) .d <- data.frame(a = letters[1:6], y =…
Robert Long
  • 5,722
  • 5
  • 29
  • 50
6
votes
2 answers

R: add text to an expression

From sfsmisc package I have an expression and I want to add a text before that. How can I add text on an expression? library(sfsmisc) v <- pretty10exp(500) title <- paste("some text ", v) plot(1:5, 1:5, main = title) This plots title as some text 5…
cNinja
  • 145
  • 6
6
votes
3 answers

how to show $\{ X_t \}$ in the title of a plot of R

How to show $\{ X_t \}$ of Latex in the title of a plot of R? For example plot(slot(x,"GRID"),slot(x,"PATH"),type="l", xlab="Time t",ylab="X", main=paste("Simulation of \{X_t\}")) Thanks!
Tim
  • 1
  • 141
  • 372
  • 590
6
votes
0 answers

`ggplotly`, plotmath expressions and double labels in legend in R

I have 2 issues using function ggplotly in R: Question 1 What are the ways to keep R plotmath expressions while converting ggplot2 plots to plotly format using function ggplotly? Now the expressions are converted to [object Object] as in this…
GegznaV
  • 4,938
  • 4
  • 23
  • 43
6
votes
1 answer

leading superscript in plotmath expression (w/ggplot2)

I'd like to use plotmath to create an axis containing a leading superscript in a ggplot2 plot. Creating superscripts on axis labels works nicely, like so: require(ggplot2) ggplot(mtcars, aes(x=disp, y=mpg)) + geom_point() + …
Drew Steen
  • 16,045
  • 12
  • 62
  • 90
6
votes
2 answers

Advanced legend in R: Plot

This is a following up question of this question: How to have a new line in a `bquote` expression used with `text`? But now I have it in a legend and this seems to change the things. I tried the…
Stat Tistician
  • 813
  • 5
  • 17
  • 45
6
votes
1 answer

Exponent in a plotmath expression

I would like to have the following, for example in a ggplot2 label: ylab(expression((hat(beta)^(2))(x))) but without the parentheses around the hat(beta)^(2). But if I remove the parentheses, then the (x) goes up to the exponent. Is there grouping…
Xu Wang
  • 10,199
  • 6
  • 44
  • 78
5
votes
3 answers

How do I write a plot containing a symbol to PDF in R?

I want to use the infinity sign on the x-axis of a box plot in R, which I want to write to a PDF file. I can set the infinity symbol by doing names(data)[9] <- "∞" but that gets me encoding errors when trying to write: conversion failure on '∞' in…
htorque
  • 1,818
  • 4
  • 19
  • 22
5
votes
2 answers

preventing centering multilayered caption in ggplot2

This is part-2 to my previous question (getting constant text size while using atop function in r). Now the issue relates to how I can prevent plotmath from centering the text to avoid the extra spacing (highlighted here in yellow). I want…
Indrajeet Patil
  • 4,673
  • 2
  • 20
  • 51
5
votes
1 answer

getting constant text size while using atop function in r

Below is a much simpler example of a complicated custom function I have written. In the full-length form of this function, "layer1"corresponds to caption entered by the user, "layer2" corresponds to results from a statistical test, and …
Indrajeet Patil
  • 4,673
  • 2
  • 20
  • 51
5
votes
2 answers

r ggplot use plotmath expressions dynamically

I want to change axis labels dynamically using ggplot. The code below is a simple version of what I'd like to do. It correctly displays a degree symbol in the y axis.The commented out ylab lines of code are what I'd like to do but fail. I want to…
JerryN
  • 2,356
  • 1
  • 15
  • 49
1 2
3
11 12