Special symbols in ggvis

会有一股神秘感。 提交于 2019-12-13 15:23:29

问题


I'm making a fairly typical plot of geochemistry profiles for which I need to use a subscript and a greek symbol in the x-axis

It should read CH4 (umol) where the 4 is subscript and the u is the greek symbol mu

ggvis code:

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)") 

Side-note: I know that I can make the proper labels in ggplot2 but I can't put the x-axis on top in ggplot2


回答1:


library(ggvis)

title <- "CH\u2084 (\u03BC mol)"

mtcars %>%
  ggvis(~wt, ~mpg) %>%
  layer_points() %>% 
  add_axis('x', orient = 'top', title = title) 

In case you need more special characters in the future, look them up here and look for "C/C++/Java source code".



来源:https://stackoverflow.com/questions/32822307/special-symbols-in-ggvis

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!