2016-11-05 80 views
1

我有四种不同的图形,每个图形都转换为grob,并取得了明显的成功。我正尝试将它们与grid.arrange()组合成一个图像。四个中的一个 - 我会说这四个中最简单的 - 会产生一个错误,即使没有其他三个。R:绘制文本Grob失败,带有神秘的错误

grid.text(expression(atop("first line", 
          scriptstyle("second line"))), 
      vjust = 0, gp=gpar(fontfamily = "HersheySans")) 

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

这是traceback()

8: grid.Call.graphics(L_text, as.graphicsAnnot(x$label), x$x, x$y, 
     resolveHJust(x$just, x$hjust), resolveVJust(x$just, x$vjust), 
     x$rot, x$check.overlap) 
7: drawDetails.text(x, recording = FALSE) 
6: drawDetails(x, recording = FALSE) 
5: drawGrob(x) 
4: recordGraphics(drawGrob(x), list(x = x), getNamespace("grid")) 
3: grid.draw.grob(tg) 
2: grid.draw(tg) 
1: grid.text(expression(atop("first line", scriptstyle("second line"))), 
     vjust = 0, gp = gpar(fontfamily = "HersheySans")) 

我得到同样的错误,如果我从功能删除scriptstylevjust,因此他们不是罪犯。

我什至不知道错误来自哪个功能。 grid.Call.graphics不会被导出,但grid:::grid.Call.graphics没有像它的代码那样的错误消息,as.graphicsAnnot, resolveHJustresolveVJust也没有。

我已经击中了这面墙。任何想法或建议如何解决这个问题或解决它非常赞赏。

Windows 7的

回答

2

下全部完成从?Hershey

不能使用数学表达式(plotmath)与Hershey字体。

这意味着Hershey字体与在?plotmath列出任何不相容,诸如scriptstyleatop,当然expression的。

+0

你是指我使用scriptstyle函数吗?这不会导致这个问题,因为当我删除scriptstyle时,我得到了完全相同的错误。但是我认为当我修复这个问题时可能会导致不同的问题。我无法在gpar fontfamily规范中找到任何非Hershey字体的文档。有这样的吗? – andrewH

+0

啊!谢谢。我没有意识到那不是基本的R“表达。” – andrewH