plotmath

Combining `expression()` with `\n`

China☆狼群 提交于 2019-11-26 14:46:17
问题 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 = 1:6) labs <- c("0-9\n(N=10)","10-29\n(N=10)","30-49\n(N=10)", + "50-64\n(N=10)","65-79\n(N=10)", expression(phantom(x) >=80)) ggplot(.d, aes(x=a,y=y)) + geom_point() + scale_x_discrete(labels = labs) How can I combine the expression() with the escape \n ?

Adding greek character to axis title

房东的猫 提交于 2019-11-26 09:29:40
问题 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. 回答1: If you

Line break in expression()?

百般思念 提交于 2019-11-26 06:40:00
问题 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),

Concatenate strings and expressions in a plot&#39;s title

扶醉桌前 提交于 2019-11-26 06:39:51
问题 How can I combine text and math expressions in a plot\'s title. If I use paste the expression is converted to character. For example I want something like this as a title $ARL_1$ curve for $S^2$ Thank you 回答1: You want to read ?plotmath to see how to do this sort of thing. Here is an example: plot(1:10, main = expression(ARL[1] ~ "curve for" ~ S^2)) The [.] is subscript, whilst ^ gives superscript. The ~ spaces out the parts of the expression as if there were literal spaces. Edit : normally I

How to change facet labels?

允我心安 提交于 2019-11-26 03:19:03
问题 I have used the following ggplot command: ggplot(survey, aes(x = age)) + stat_bin(aes(n = nrow(h3), y = ..count.. / n), binwidth = 10) + scale_y_continuous(formatter = \"percent\", breaks = c(0, 0.1, 0.2)) + facet_grid(hospital ~ .) + theme(panel.background = theme_blank()) to produce I\'d like to change the facet labels, however, to something shorter (like Hosp 1 , Hosp 2 ...) because they are too long now and look cramped (increasing the height of the graph is not an option, it would take