R: Lattice ruined the legend in pdf

I create a barrier to the distribution of the “DISTANCE” portion of the “STATUS” variable in the data . My code is as follows:

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 file here . Why does the legend print "≤" as "..." when the ">" prints well? This only happens with pdf or eps. If I use png, the output

+5
source share
1 answer

It should work when using a cairo PDF PDF file, for example

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

Although I have not tested it, this may be related to the PDF encoding, see Including Trendy Glyphs in R Graphics PDF output , by Paul Murrell.

+2
source

All Articles