R:格子在pdf中混淆了传奇

时间:2012-07-13 04:32:46

标签: r lattice

我正在创建this数据中变量“STATE”中“DISTANCE”比例分布的条形图。我的代码如下:

library(R.utils)
df = loadObject("bchart.bin")
df.prop = as.data.frame(prop.table(table(df$STATE, df$DISTANCE),1)) #Creating proportions data
  names(df.prop) = c('State','Distance','Proportion')

library(lattice)
pdf(file="bchart.pdf", width=10, height=10, pointsize=10)
barchart(State ~ Proportion, groups=Distance, data=df.prop, stack=T, horizontal=T, auto.key=list(columns=5, space="top"), par.settings = list(superpose.polygon = list(col = rev(gray.colors(5))))) 
dev.off()

pdf文件为here。为什么图例在'>'时将'≤'打印为'...'打印好吗?这只发生在pdf或eps上。如果我使用png,output is fine

1 个答案:

答案 0 :(得分:2)

使用cairo PDF后端时应该可以使用,例如

cairo_pdf(file="bchart.pdf", width=10, height=10, pointsize=10)

虽然我没有检查过,但这可能与PDF编码有关,请参阅Including fancy glyphs in R Graphics PDF output,Paul Murrell。