R:绘制textGrob失败,出现神秘错误



我有四种不同类型的图形,每一种都成功地转换为grob。我试图将它们与grid.arrange()组合成一个图像。其中一种——我认为是四种中最简单的一种——即使没有其他三种,也会产生错误。

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下完成

From ?Hershey

您不能将数学表达式(plotmath)与好时字体一起使用。

这意味着好时字体与?plotmath中列出的任何内容都不兼容,例如scriptstyle, atop,当然还有expression

最新更新