我正在制作一个相当典型的地球化学剖面图,我需要在 x 轴上使用下标和希腊符号
它应该读作 CH4 (umol),其中 4 是下标,u 是希腊符号 mu
ggvis代码:
ch4 %>% ggvis(~ch4_umol, ~depth_cm, fill=~Core, stroke=~Core) %>%
layer_lines(fillOpacity=0) %>% scale_numeric('y', reverse=T) %>%
add_axis("y", title = "Depth (cm)") %>%
add_axis('x', orient='top', title="CH[4] ("mu "mol)")
旁注:我知道我可以在 ggplot2 中制作正确的标签,但我无法将 x 轴放在 ggplot2 的顶部
最佳答案
library(ggvis)
title <- "CH\u2084 (\u03BC mol)"
mtcars %>%
ggvis(~wt, ~mpg) %>%
layer_points() %>%
add_axis('x', orient = 'top', title = title)
如果您将来需要更多特殊字符,请查找它们 here并查找“C/C++/Java 源代码”。
关于r - ggvis中的特殊符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32822307/