r - ggvis中的特殊符号

标签 r plot ggvis

我正在制作一个相当典型的地球化学剖面图,我需要在 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) 

enter image description here

如果您将来需要更多特殊字符,请查找它们 here并查找“C/C++/Java 源代码”。

关于r - ggvis中的特殊符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32822307/

相关文章:

regex - R-使用通配符替换字符串的一部分

r - 如何使用 R 函数 download.file?

r - 线性回归线无法在 r 中的时间序列图上显示

Shiny 的应用程序 selectInput 和 radioButtons 中的响应式(Reactive)更新 - ggvis

r - 带有 ggvis : how to plot multiple groups with different shape markers and corresponding fitted regression lines 的 R 中的散点图

python - 如何使用Python或R对大数据进行聚类而不出现内存错误?

r - 按组填充多列的缺失值

Matlab 将单个子图保存为 jpg

matlab - 格林函数的傅里叶变换 - 两个信号之间的差异几乎相同

r - ggvis plot 随机消失 Shiny