ggvis 中的特殊符号 [英] Special symbols in ggvis

查看:62
本文介绍了ggvis 中的特殊符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在绘制一个相当典型的地球化学剖面图,我需要在 x 轴上使用下标和希腊符号

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

它应该是 CH4 (umol),其中 4 是下标,而 u 是希腊符号 mu

It should read CH4 (umol) where the 4 is subscript and the u is the greek symbol 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 的顶部

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

推荐答案

library(ggvis)

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

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

如果您将来需要更多特殊字符,请查找它们在这里并寻找C/C++/Java源代码".

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

这篇关于ggvis 中的特殊符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆