Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R: Lattice messes up legend in pdf

Tags:

r

lattice

I am creating a barchart of the distribution of the proportion of "DISTANCE" across the variable "STATE" in this 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()

The pdf file is here. Why is the legend printing the '≤' as '...' when the '>' is printing fine? This is happening only with pdf or eps. If I use png, the output is fine.

like image 503
user702432 Avatar asked Nov 03 '22 20:11

user702432


1 Answers

It should work when using the cairo PDF backend, e.g.

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

Although I haven't checked, this might well have to do with PDF encoding, see Including fancy glyphs in R Graphics PDF output, by Paul Murrell.

like image 123
chl Avatar answered Nov 07 '22 21:11

chl