R plotmath - 在表达式中加上“à”

时间:2015-04-23 09:23:28

标签: r ggplot2 plotmath

我使用expression包中的plotmath将一个轴标题分为两行(我正在使用expression,因为我需要一半的标题文字和一半粗体) 。

我需要在标题中包含字符“à”(它是法语),但以下代码不起作用:

xlab(expression(atop(first_line,bold(Age~"\u00E0"~la~"1e"~naissance))))

产生以下错误消息:

Error in grid.Call.graphics(L_text, as.graphicsAnnot(x$label), x$x, x$y,  :
Metric information not available for this family/device

编辑:可行的示例:

library(ggplot2)
data<-as.data.frame(c("a","b","c","a","b","c"))
colnames(data)<-"Y"

data$X<-c(1:6)

data$Z<-c(1,2,3,1,2,3)

ggplot(data, aes(x=X)) + 
  geom_line(aes(y = Z), size=0.43) +
  xlab(expression(atop(top,bold(Age~"à"~la~"1e"~naissance))))

会话信息:

R version 2.15.2 (2012-10-26)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=French_France.1252  LC_CTYPE=French_France.1252    LC_MONETARY=French_France.1252
[4] LC_NUMERIC=C                   LC_TIME=French_France.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] ggplot2_0.9.3.1

loaded via a namespace (and not attached):
 [1] colorspace_1.2-4   dichromat_2.0-0    digest_0.6.4       grid_2.15.2        gtable_0.1.2       labeling_0.2      
 [7] MASS_7.3-23        munsell_0.4.2      plyr_1.8           proto_0.3-10       RColorBrewer_1.0-5 reshape2_1.2.2    
[13] scales_0.2.3       stringr_0.6.2      tools_2.15.2

0 个答案:

没有答案