第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

ggplot2兩行帶有表達(dá)式的標(biāo)簽

ggplot2兩行帶有表達(dá)式的標(biāo)簽

慕尼黑5688855 2019-10-18 09:49:47
我想用一條expression()語句在兩行上寫一個(gè)軸標(biāo)簽。但是,plotmath并且expression也不允許這樣做(例如,在最右邊顯示帶下標(biāo)的文本)。我在2005年左右發(fā)現(xiàn)了類似問題的討論,但是他們提供的解決方案并沒有轉(zhuǎn)化為ggplot2中的我的應(yīng)用程序。最近的一個(gè)問題解決了多行表達(dá)式語句的其他排列問題,但是同樣,此處提供的解決方法也不適用。例:p <- ggplot(mtcars,aes(x=wt,y=mpg))+  geom_point()+  xlab(expression(paste("A long string of text goes here just for the purpose \n of illustrating my point Weight "[reported])))try(ggsave(plot=p,filename=<some file>,height=4,width=6))產(chǎn)生一個(gè)圖像,當(dāng)我希望下標(biāo)“ reported”位于前一個(gè)單詞的旁邊時(shí),該圖像會(huì)被踢到右側(cè)。 
查看完整描述

3 回答

?
大話西游666

TA貢獻(xiàn)1817條經(jīng)驗(yàn) 獲得超14個(gè)贊

你可以用這個(gè)把戲


library(gridExtra)

library(grid)


element_custom <- function() {

  structure(list(), class = c("element_custom", "element_text"))

}


element_grob.element_custom <- function(element, label="", ...)  {


  mytheme <- ttheme_minimal(core = list(fg_params = list(parse=TRUE, 

                                                         hjust=0, x=0.1)))

  disect <- strsplit(label, "\\n")[[1]]

  tableGrob(as.matrix(disect), theme=mytheme)

}


# default method is unreliable

heightDetails.gtable <- function(x) sum(x$heights)


ggplot(iris, aes(Sepal.Length, Sepal.Width)) +

  geom_line() + 

  labs(x= "First~line \n italic('and a second') \n integral(f(x)*dx, a, b)")+

  (theme_grey() %+replace% theme(axis.title.x = element_custom()))

http://img1.sycdn.imooc.com//5da91aaa00019aac04810446.jpg

查看完整回答
反對(duì) 回復(fù) 2019-10-18
  • 3 回答
  • 0 關(guān)注
  • 1644 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)