plotmath

How to use italic in label_bquote for strip text lables

天大地大妈咪最大 提交于 2021-02-11 14:29:58
问题 There have been many proposed solutions to many slightly different problems, but none quite catches my specific problem. What I want is the following: I want to mix normal subfig labels (a, b, c, ...) with species names in italics . So far, I only want do this for four species, so I could live with a manual solution. But a custom function automatizing the process would be neat... E.g. the strip text of species a would be: a) Genus species Here is a reproducible example with the iris dataset:

R / ggplot2: Evaluate object inside expression

荒凉一梦 提交于 2020-08-19 11:49:42
问题 Example code: rsq <- round(cor(mtcars$disp, mtcars$mpg)^2, 2) # rsq = 0.72 ggplot(mtcars, aes(x = disp, y = mpg)) + geom_point() + geom_smooth(method = lm, aes(color = "Linear")) + scale_color_discrete(labels = expression(paste("R"^2, " = ", rsq))) I would like the legend to be displayed as R² = 0.72 . I know I can just use the unicode symbol for ² to get the superscript, but in general I think there has to be a way to combine math expressions and calculated values stored in objects. I have

degree symbol incorrect in map axis labels

痞子三分冷 提交于 2020-06-27 18:12:34
问题 If I create maps using geom_sf , the axis labels have the wrong symbol for degrees. I get degree symbols that are vertically centred in the text, rather than raised like superscipts. For example, library(sf) library(ggplot2) nc = st_read(system.file("shape/nc.shp", package="sf")) ggplot() + geom_sf(data = nc) + theme(axis.text = element_text(size=16)) When I see examples online, they typically look correct (e.g. image below, copied from here), so I guess it is related to something in my local

How to fix degree symbol not showing correctly in R on Linux/Fedora 31

久未见 提交于 2020-03-22 04:30:13
问题 This bounty has ended . Answers to this question are eligible for a +50 reputation bounty. Bounty grace period ends in 19 hours . giocomai wants to draw more attention to this question. Any map I make with: ggplot() + geom_sf() produces the expected map, but does not show the degree sign correctly, as appears from the following picture. The answer given in this answer on SO - degree symbol incorrect in map axis labels - does not help, and I am posting a separate question as I see a different

How to fix degree symbol not showing correctly in R on Linux/Fedora 31

流过昼夜 提交于 2020-03-22 04:29:22
问题 This bounty has ended . Answers to this question are eligible for a +50 reputation bounty. Bounty grace period ends in 19 hours . giocomai wants to draw more attention to this question. Any map I make with: ggplot() + geom_sf() produces the expected map, but does not show the degree sign correctly, as appears from the following picture. The answer given in this answer on SO - degree symbol incorrect in map axis labels - does not help, and I am posting a separate question as I see a different

How to fix degree symbol not showing correctly in R on Linux/Fedora 31

蓝咒 提交于 2020-03-22 04:28:10
问题 This bounty has ended . Answers to this question are eligible for a +50 reputation bounty. Bounty grace period ends in 19 hours . giocomai wants to draw more attention to this question. Any map I make with: ggplot() + geom_sf() produces the expected map, but does not show the degree sign correctly, as appears from the following picture. The answer given in this answer on SO - degree symbol incorrect in map axis labels - does not help, and I am posting a separate question as I see a different

Chemical formula (or mathematical expression) in GNU R plot title

ⅰ亾dé卋堺 提交于 2020-01-23 02:56:07
问题 How can i write H2o in the title of a plot? H2 works: plot(main=expression("H"[2]),0) H2O fails: plot(main=expression("H"[2]"O"),0) This solution will work only, if i have a space in front " " plot(main=expression(" "*H[2]*"O"),0) 回答1: You were close. This works: plot(1:10, main = expression(H[2]*O)) The reason for this is that the 2 is a subscript to element H and you want to position element O next to the H . The notation x * y in an expression means juxtapose x with y , i.e. place x and y

How to use more than one expression in a row

本秂侑毒 提交于 2020-01-14 09:57:07
问题 I am new to R and I am trying to figure out, how to write something like "Hey guys, this is my plot for (\n)8 <=(less than or equal) x <= 10" in my plot-title. I tried something like this: plot(1:10, main="Hey, guys, this is my plot for \n") mtext(c(expression(8 <= x),expression(x <= 10), side=3) This gives not exactly what I want but "8 (less or equal) x x (less or equal) 10", and those two expressions are printed in a line below the main title, (which is pretty cool) but in the same place,

Equal spacing with multiple atop

二次信任 提交于 2020-01-14 05:44:09
问题 I'm trying to create a legend in a ggplot2 graph with multiple lines and a parameter and value on each line. Since I have symbols as variables, this needs to be done with expression . To create new lines, I have used multiple atop commands, but this leads to uneven spacing in the final line. Please see my following example: library(ggplot2) N = 25 a = -5 b = 2 sigma = 1 x = runif(N, 0, 10) y = a + x * b + rnorm(N, sd = sigma) df = data.frame(x, y) ggplot(df, aes(x, y)) + geom_point() + geom