2013-06-05 235 views
1

我想在ggplot中設置粗體標籤和標記,但y軸標籤未設置爲粗體。請建議我應該添加到腳本中。以下是一個可重複的例子。我需要'atop'命令來設置y軸標籤字符串,如下例所示。在ggplot中使y軸標籤爲粗體(x軸設置爲粗體,但y軸標籤不變)

在此先感謝。

library(ggplot2) 

chart <- ggplot(diamonds, aes(x = table, fill = clarity)) + 

geom_histogram() + 

    scale_x_continuous('Month') + 

scale_y_continuous(expression(atop('ET (W'~m^-2~')'))) 

chart<-chart+theme(axis.title.y = element_text(colour="grey20",size=20,face="bold"), 
    axis.text.x = element_text(colour="grey20",size=20,face="bold"), 
    axis.text.y = element_text(colour="grey20",size=20,face="bold"), 
    axis.title.x = element_text(colour="grey20",size=20,face="bold")) 

print(chart) 
+0

這適用於我。答案可能在於您的操作系統的特定功能(例如安裝的字體等)。 'sessionInfo()'的輸出將是一個開始。 – joran

+0

我正在使用:R版本2.15.2(2012-10-26) 平臺:i386-w64-mingw32/i386(32位) – Munish

+0

不在評論中!在你的問題! – joran

回答

0

我有一個類似的問題,得到了這個工作:

ylab(expression(atop(bold('ET (W'~m^-2~')'), paste(bold('something else'[here]))))) 

希望有所幫助。