【问题标题】:R: Lattice messes up legend in pdfR:格子在pdf中弄乱了图例
【发布时间】:2012-07-13 04:32:45
【问题描述】:

我正在创建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.

【问题讨论】:

    标签: r lattice


    【解决方案1】:

    它应该在使用 cairo PDF 后端时工作,例如

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

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

    【讨论】:

    • 这可能是编码问题。非latin1 语言每天都在处理这个问题,这并不好。
    猜你喜欢
    • 1970-01-01
    • 2014-02-03
    • 1970-01-01
    • 2020-12-13
    • 1970-01-01
    • 1970-01-01
    • 2021-01-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多