在PDF中绘制符号失败 [英] Plotting symbols fails in PDF

查看:170
本文介绍了在PDF中绘制符号失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码来创建plot.在x-和y-axes上,当以这种格式保存绘图时,在屏幕上显示symbols,在JPEG中,但在将绘图另存为PDF时,显示在JPEG中. >

我的\u2030是否有其他符号可以在PDF或其他解决方案中打印?请参见下面的示例(正确的JPEG格式和错误的PDF格式).

plot(c(-1,1), c(-1,1), bty = "n", type= "n", las = 1, cex.lab = 1.5, cex.axis = 1.25, main = NULL, 
ylab=expression(paste("Correlation Coefficient (r) for ", delta ^{15},"N"," \u0028","\u2030","\u0029")), 
xlab=expression(paste("Correlation Coefficient (r) for ", delta ^{13},"C"," \u0028","\u2030","\u0029")))
axis(1, at = seq(-1.0, 1.0, by = 0.1), labels = F, pos = 0, cex.axis = 0.05, tcl = 0.25)
axis(2, at = seq(-1.0, 1.0, by = 0.1), labels = F, pos = 0, cex.axis = 0.05, tcl = 0.25)

解决方案

问题是您的默认字体不像\ u0028生成的字形那样具有‰"(我会说"per mil") .您需要更改为具有该字形的字体:

?pdfFonts

这是我在没有任何问题(至少据我所知)的情况下得到的设置

> str(pdfFonts("sans"))
List of 1
 $ sans:List of 3
  ..$ family  : chr "Helvetica"
  ..$ metrics : chr [1:5] "Helvetica.afm" "Helvetica-Bold.afm" "Helvetica-Oblique.afm" "Helvetica-BoldOblique.afm" ...
  ..$ encoding: chr "default"
  ..- attr(*, "class")= chr "Type1Font"

I have the following code to create a plot. On the x- and y-axes there are symbols that appear on the screen, in a JPEG when I save my plot in that format, but not when I save the plot as a PDF.

Is there alternative symbol to my \u2030 that will print in my PDF or another solution to my problem? See examples below of the correct (JPEG format) and the incorrect (PDF) plots .

plot(c(-1,1), c(-1,1), bty = "n", type= "n", las = 1, cex.lab = 1.5, cex.axis = 1.25, main = NULL, 
ylab=expression(paste("Correlation Coefficient (r) for ", delta ^{15},"N"," \u0028","\u2030","\u0029")), 
xlab=expression(paste("Correlation Coefficient (r) for ", delta ^{13},"C"," \u0028","\u2030","\u0029")))
axis(1, at = seq(-1.0, 1.0, by = 0.1), labels = F, pos = 0, cex.axis = 0.05, tcl = 0.25)
axis(2, at = seq(-1.0, 1.0, by = 0.1), labels = F, pos = 0, cex.axis = 0.05, tcl = 0.25)

解决方案

The problem is that your default font does not have "‰" (which I would speak as "per mil") as the glyph that is produced with \u0028. You need to change to a font that does have that glyph:

?pdfFonts

This is what I get with my setup where there is no problem (at least as I understand ti.)

> str(pdfFonts("sans"))
List of 1
 $ sans:List of 3
  ..$ family  : chr "Helvetica"
  ..$ metrics : chr [1:5] "Helvetica.afm" "Helvetica-Bold.afm" "Helvetica-Oblique.afm" "Helvetica-BoldOblique.afm" ...
  ..$ encoding: chr "default"
  ..- attr(*, "class")= chr "Type1Font"

这篇关于在PDF中绘制符号失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆