plotmath

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

陌路散爱 提交于 2019-12-01 09:08:46
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. Relationship between diffuse attenuation coefficient at 490 nm (K"[d]*") and chlorophyll concentration at three coral reef sites"), xlab=expression("Chlorophyll concentration (mg "*m^{-3}*")"), cex.lab=0.8, cex.main=0.8, cex.axis=0.8, font.main=1, ylim=c(0,0.3), xlim=c(0,3.5), ylab=expression("K"[d]*"(m"*-1^{-1}*")")) You did not specify, where you want to break the

multiple bquote items in legend of an R plot

柔情痞子 提交于 2019-11-30 18:17:31
Following works, (copy & paste into R) a=123 plot(1,1) legend('bottomleft',legend=bquote(theta == .(a))) I want to have multiple items in the legend. All with greek letters. As a simple example, if I repeat the item twice the code does not work anymore a=123 plot(1,1) legend('bottomleft',legend=c(bquote(theta == .(a)),bquote(theta == .(a)))) I have tried many more complicated expressions but they all did not work. Any help will be appreciated. In this case, plotmath is not able to coerce the list of calls to expressions. > cs <- c(bquote(theta == .(a)),bquote(theta == .(a))) > cs [[1]] theta =

How to have a new line in a `bquote` expression used with `text`?

浪子不回头ぞ 提交于 2019-11-30 03:10:19
问题 This question was migrated from Cross Validated because it can be answered on Stack Overflow. Migrated 6 years ago . I want to have a new line in my bquote envrionment, how can I do this? my code: test<-c(1,2,3,4,4.5,3.5,5.6) test2<-0.033111111 plot(test,c(1:length(test))) segments(4,0,4,23,col="red",lwd=2) text(5, 4.5, labels = bquote(Qua[0.99] == .(round(test2,4))),col="red", cex = 1.4) And I want to have a new line after the equal sign, so this should give: VaR_0.99 = 0.03311 and not VaR_0

multiple bquote items in legend of an R plot

自作多情 提交于 2019-11-30 02:23:47
问题 Following works, (copy & paste into R) a=123 plot(1,1) legend('bottomleft',legend=bquote(theta == .(a))) I want to have multiple items in the legend. All with greek letters. As a simple example, if I repeat the item twice the code does not work anymore a=123 plot(1,1) legend('bottomleft',legend=c(bquote(theta == .(a)),bquote(theta == .(a)))) I have tried many more complicated expressions but they all did not work. Any help will be appreciated. 回答1: In this case, plotmath is not able to coerce

Use dataframe variable names in plot titles

左心房为你撑大大i 提交于 2019-11-29 16:47:30
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 <- data.frame( origin = sample(c("hum_1", "mou_1"), 100, replace = TRUE), v1 = rnorm(100, 100, 5), v2 = rnorm(100, 10,5), v3 = rnorm (100, 25, 5)) example.df <- example.df %>% set_variable_labels(origin = "original sample", v1 = "effect of Rx", v2 = "response", v3 = "weight (kg)") This gets the labels to show up in the dataframe. However, when I use ggqqplot from

How do I include italic text in geom_text_repel or geom_text labels for ggplot?

試著忘記壹切 提交于 2019-11-29 07:33:26
Is it possible to pass partially italicized text labels into ggplot? I have tried using the expression and italic commands ( expression(paste(italic("some text"))) ), but these cannot be passed into a data frame because the result of the commands is not atomic. Setting the parameter fontface = "italic" also doesn't suffice, since this italicizes the entire label, rather than just a select set of characters in the label. For instance, I would like some necessarily italicized Latin phrases to be italicized in a label (such as "in vivo" in "in vivo point"). library(ggplot) library(ggrepel) df <-

Using plotmath in ggplot2 with percent sign (%)

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-29 04:16:30
I would like to use Greek characters, Latin characters and the percent sign in the facet labels of a ggplot2 bar chart. Greek characters can be done with 'facet_grid(.~variable, labeller=label_parsed)': a<-c("Delta~V","VarcoV","Delta~V","VarcoV") b<-c(1,2,3,4) d<-c("one","one","two","two") mydata<-data.frame(cbind(b,a,d)) ggplot(mydata,aes(x=d,y=b))+facet_grid(.~a, labeller=label_parsed)+geom_bar(stat="identity") Now I also want to add a facet label that includes % and a Latin character: a<-c("Delta~V","VarcoV","%V","Delta~V","VarcoV","%V") b<-c(1,2,3,4,5,6) d<-c("one","one","one","two","two",

Mathematical expression in axis label

此生再无相见时 提交于 2019-11-29 03:12:48
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("test.tex", standAlone=TRUE, width=5, height=5) plot(1:10, 1:10, xlab="$\\theta_\\ell$") dev.off()

Using italic() with a variable in ggplot2 title expression

送分小仙女□ 提交于 2019-11-28 14:03:00
When I make a map using ggplot2 and attempt to italicize part of the figure title using a combination of expression() and italic() using a string, my map comes out as desired: plottitle <- expression(paste('Example map with ', italic('italics'))) crimes <- data.frame(state = tolower(rownames(USArrests)), USArrests) states_map <- map_data("state") map <- ggplot(crimes, aes(map_id = state)) + geom_map(aes(fill = Murder), map = states_map) + expand_limits(x = states_map$long, y = states_map$lat) + labs(title = plottitle) map However, when I try to do the same thing, but use an object instead of a

Special characters and superscripts on plot axis titles

被刻印的时光 ゝ 提交于 2019-11-28 04:06:49
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, "Moles/cm"^"2"),)), data = plates) The one thing that often users fail to grasp is that you invariably