斜体和上标在ggplot轴标题中的表达 [英] Expression of italics and superscripts in ggplot axis title

查看:956
本文介绍了斜体和上标在ggplot轴标题中的表达的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很抱歉问这个问题,但是我似乎无法得到这个表达式来包含 ylab() xlab )一个ggplot2对象的参数。它需要阅读:

2q (稀薄)。但是,2需要上传。



我弄了表达式() paste(),但它似乎不可能。



编辑:例如:

 数据< -as.data.frame(matrix(runif(100),10,10))
names(dat)< - LETTERS [1:10]

library(ggplot2)
ggplot(dat,aes(A,B))+
geom_point()+
xlab(some title)

解决方案

所有必要的信息都可以在 help(plotmath)中找到

$ pre $ g $ p $ ggplot(dat,aes(A,B))+
geom_point()+
xlab (表达式({} ^ 2 * italic(q)〜textstyle(group((,rarefied,)))))


I am sorry to ask this, but I can't seem to get this expression right to include in the ylab() or xlab() arguments of a ggplot2-object. It needs to read:

"2q (rarefied)". The "2" needs to superscripted, though.

I have fiddled with expression() and paste(), but it seems impossible. Any help is much appreciated.

edit: Some example:

dat<-as.data.frame(matrix(runif(100), 10,10))
names(dat) <- LETTERS[1:10]

library(ggplot2)
ggplot(dat, aes(A,B)) +
  geom_point()+
  xlab("some title")

解决方案

All necessary information can be found in help("plotmath").

ggplot(dat, aes(A,B)) +
  geom_point()+
  xlab(expression({}^2*italic(q)~textstyle(group("(", rarefied, ")"))))

这篇关于斜体和上标在ggplot轴标题中的表达的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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