7

Rでカラーバーとラスターマップを作成しようとしていますが、PDFにエクスポートすると、出力図に見苦しい線が表示されます。

カラーバーを生成するコードは次のとおりです。Rで実行すると問題ないように見えます。

color.bar <- function(lut, min, max=-min, nticks=11, ticks=seq(min, max, len=nticks), title='') {
    scale = (length(lut)-1)/(max-min)

    plot(c(0,10), c(min,max), type='n', bty='n', xaxt='n', xlab='', yaxt='n', ylab='', main=title)
    axis(4, ticks, las=1)
    for (i in 1:(length(lut)-1)) {
     y = (i-1)/scale + min
     rect(0,y,10,y+1/scale, col=lut[i], border=NA)
    }
}

par(mfrow=c(2,1))
par(mar=c(3,0,3,2.5))
pal = colorRampPalette(c("red","yellow"))
neg = pal(100)
pal = colorRampPalette(c("yellow","darkgreen"))
pos = pal(50)
color.bar(c(neg,pos),min=-75,max=50,ticks=c(-75,-50,-25,0,25,50))
color.bar(colorRampPalette(c("goldenrod","blue"))(25),min=0,max=1)
par(mar=c(5.1,4.1,4.1,2.1))
    dev.copy2pdf(file = "colorbar_wood.pdf", height = 8, width = 1)
pdf("colorbar_wood.pdf",width=1,height=8)
par(mfrow=c(2,1))
par(mar=c(3,0,3,2.5))
pal = colorRampPalette(c("red","yellow"))
neg = pal(100)
pal = colorRampPalette(c("yellow","darkgreen"))
pos = pal(50)
color.bar(c(neg,pos),min=-75,max=50,ticks=c(-75,-50,-25,0,25,50))
color.bar(colorRampPalette(c("goldenrod","blue"))(25),min=0,max=1)
par(mar=c(5.1,4.1,4.1,2.1))
 dev.off()

そして、これが私がpdfとして出すものです:

リンク

私はこれを出版物の品質に合わせる必要があります。修正する方法について何かアイデアはありますか?

4

1 に答える 1

6

これは、RではなくPDFのレンダリングに使用されるソフトウェアで常に問題になり、PDFを表示するためにPDFビューアが行うアンチエイリアシングやその他のレンダリング操作などの機能が原因で発生します。

これは?pdf、特にで説明されています

Note:

     If you see problems with PDF output, do remember that the problem
     is much more likely to be in your viewer than in R.  Try another
     viewer if possible.  Symptoms for which the viewer has been at
     fault are apparent grids on image plots (turn off graphics
     anti-aliasing in your viewer if you can) and missing or incorrect
     glyphs in text (viewers silently doing font substitution).

     Unfortunately the default viewers on most Linux and Mac OS X
     systems have these problems, and no obvious way to turn off
     graphics anti-aliasing.

     ....

Linux上の2つの異なるPDFビューア(EvinceとOkular)でPDFを表示しましたが、これらのアーティファクトがファイルに与える影響の程度は2つのビューア間で異なり、Okularは赤緑のアーティファクトが少なく、青のアーティファクトはありませんでした。 -黄色のもの。そのため、これはPDFの表示に関する問題であり、Rに関する問題ではないようです。したがって、図は出版品質である必要があります。

于 2013-03-26T02:45:31.887 に答える