本文介绍了如何在R中将包含符号的图形写入PDF?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在R中的箱形图的x轴上使用无穷大符号,我想将其写入PDF文件.

I want to use the infinity sign on the x-axis of a box plot in R, which I want to write to a PDF file.

我可以通过设置无穷大符号

I can set the infinity symbol by doing

names(data)[9] <- "∞"

但这会在尝试编写时使我出现编码错误:

but that gets me encoding errors when trying to write:

conversion failure on '∞' in 'mbcsToSbcs': dot substituted for <...>

推荐答案

您可以按照以下示例使用Unicode:(无穷大是Unicode 8734):特别是,仅使用cairoPDF设备就可以完成此工作.可能更好的主意是使用?plotmath功能(如?boxplot自变量下在?boxplot中所引用:

You can either use Unicode as in this example: using Unicode 'dingbat-like' glyphs in R graphics, across devices & platforms, especially PDF (infinity is Unicode 8734): in particular, it's possible that simply using a cairoPDF device will make this work. Probably a better idea is to use ?plotmath capabilities (as referenced in ?boxplot under the names argument:

 boxplot(matrix(1:10,ncol=2),names=c("a",expression(infinity)))

这篇关于如何在R中将包含符号的图形写入PDF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!