plotmath

Include text control characters in plotmath expressions

本小妞迷上赌 提交于 2019-11-27 23:56:43
Is there any way to get control characters for text strings, e.g. "\n" for newline evaluated inside a plotmath expression, or vice versa. In the following example, I would like to combine: some character text text control character (newline) substitute a variable name include a plotmath expression After reading this question I can get most of the way there with substitute, but the newline character is not evaluated. I am now going round in circles and confusing myself with plotmath , parse , bquote and substitute . In the help page for plotmath it says Control characters (e.g. \n) are not

Mathematical expression in axis label

有些话、适合烂在心里 提交于 2019-11-27 22:07:04
问题 In R, I use expression(theta[l]) so that the label of my plot axis is that same as $\theta_l$ from LaTeX. For esthetic reasons, I'd rather like to display $\theta_\ell$ . Can you help me? EDIT Before, I did plot(1:10, 1:10, xlab=expression(theta[l])) and I exported the resulting picture in pdf. Then, using \begin{figure}[htbp] \centerline{\includegraphics[scale=.6]{test.pdf}} \end{figure} my picture was inserted in LaTeX. Following the comments, here is what I now do: require(tikzDevice) tikz

Plot main title in two lines

走远了吗. 提交于 2019-11-27 13:47:54
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, main=paste("C=1", "\n", "SumXi=2")) I guess bquote makes something wrong... (look up ?bquote) I tried to change environment in bqoute (the where-argument) but I don't know which environment to take. BTW: plot(1:10, main=bquote(paste("C=", .(CVal), "bla \n ", sum(xi), "=", .(SumEpsVal) ))) makes something crazy with the "bla". The root issue is that

Use a variable within a plotmath expression

怎甘沉沦 提交于 2019-11-27 04:22:32
I'm trying to place the results of a regression (i.e., R2) in a graph, but can't seem to figure out how to call a variable from within an expression (it pastes the variable name). Here is my code. R2Val <- signif(summary(sMod_pre90)$r.squared[1], 2) text(92, 4, expression(paste(R^2, " = ", R2Val)), adj = 0, cex = 0.85) Use bquote() . Here is an example with dummy data: set.seed(1) DF <- data.frame(A = rnorm(100), B = rnorm(100)) mod <- lm(B ~ A, data = DF) R2Val<-signif(summary(mod)$r.squared[1], 2) The parts of the expression wrapped in .() get evaluated in the environment, i.e. the value of

Displaying a greater than or equal sign

旧城冷巷雨未停 提交于 2019-11-27 04:21:47
I have a plot which is generated thus: ggplot(dt.2, aes(x=AgeGroup, y=Prevalence)) + geom_errorbar(aes(ymin=lower, ymax=upper), colour="black", width=.2) + geom_point(size=2, colour="Red") I control the x axis labels like this: scale_x_discrete(labels=c("0-29","30-49","50-64","65-79",">80","All")) + This works but I need to change the ">80" label to "≥80". However "≥80" is displayed as "=80". How can I display the greater than or equal sign ? An alternative to using expressions is Unicode characters, in this case Unicode Character 'GREATER-THAN OR EQUAL TO' (U+2265). Copying @mnel's example .d

Line break in expression()?

ぃ、小莉子 提交于 2019-11-27 01:16:10
I have the following histogram in R: hist(alpha,cex.main=2,cex.axis=1.2,cex.lab=1.2, main=expression(paste("Histogram of ",hat(mu), ", Bootstrap samples, Allianz"))) The titlle is too long, so I want a line break. According to this thread I tried hist(alpha,cex.main=2,cex.axis=1.2,cex.lab=1.2, main=expression(paste("Histogram of ",hat(mu), ",cat("\n") Bootstrap samples, Allianz"))) or hist(alpha,cex.main=2,cex.axis=1.2,cex.lab=1.2, main=expression(paste("Histogram of ",hat(mu), cat("\n"),", Bootstrap samples, Allianz"))) But both do not work, how can I get a line break in paste()? You can

Adding greek character to axis title

人走茶凉 提交于 2019-11-27 00:54:55
I want to add a greek character to the y-axis of my barplot in R. The problem is that I need this character to be integrated in the title. I want to write: Diameter of aperture ("mu"m) in the axis label. With ylab=expression() I can write the greek character, with ylab="axis title" I can write the title with proper spaces between the words. But I can't find a way to put all these together and write a proper label with a greek word in the axis label. I hope I was clear enough. If you're using plotmath{grDevices} , the main help page ( plotmath ) contains an example of what you appear to want:

Special characters and superscripts on plot axis titles

烈酒焚心 提交于 2019-11-27 00:17:09
问题 I am trying to make a y-axis title with both a special character and a superscript. I am able to do this, but I want the closing parentheses not to be superscripted. And that's what I'm having a problem with. I think its just a placing of my parenthesis, but I've tried (seemingly) everything. plot(WatexCl, ConcuM, col = as.numeric(1), pch = as.numeric(Depth), xlab = expression(paste("Concentration Cl ( ", mu, "moles/g dry wt)")), ylab = expression(paste("Average Conc of S- on plates ( ", mu,

Include text control characters in plotmath expressions

倖福魔咒の 提交于 2019-11-26 21:36:50
问题 Is there any way to get control characters for text strings, e.g. "\n" for newline evaluated inside a plotmath expression, or vice versa. In the following example, I would like to combine: some character text text control character (newline) substitute a variable name include a plotmath expression After reading this question I can get most of the way there with substitute, but the newline character is not evaluated. I am now going round in circles and confusing myself with plotmath , parse ,

Plot main title in two lines

只愿长相守 提交于 2019-11-26 16:28:58
问题 This question was migrated from Cross Validated because it can be answered on Stack Overflow. Migrated 6 years ago . 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, main=paste("C=1", "\n", "SumXi=2")) I guess bquote makes something wrong... (look up ?bquote) I tried to change environment in bqoute