[R-lang] wonky PDF labelling behavior in R

Harry J Tily hjt at stanford.edu
Fri Jul 24 23:50:40 PDT 2009


Hi Paula

I think the problem is that hist() is itself a plotting command -- you
don't need to wrap it in plot() at all. It turns out that hist *also*
returns a histogram object which you can then plot with plot(), so when
you do that the X display immediately replaces the figure created by
hist() with the one created by plot()... but the pdf device saves the
first figure, the one created directly by hist().

Try passing the graphical parameters (xlab, etc) directly to hist(), or
use plot=F as a parameter to hist() if you want to use plot() to do the
rendering.

Hal
-- 

On Fri, 2009-07-24 at 11:53 -0600, Paula Chesley wrote:
> Hi everyone,
> 
> When trying to plot a pdf of a certain linguistic distribution, I am  
> having trouble having the labels I give as arguments show up in the  
> PDF. What shows up in the PDF are the unhelpful default labels R  
> gives. This is really strange, because I've done the same thing  
> several times no problem, and on the default x11 output the correct  
> labels show up. See attached figure 1 (correct labelling on x11) and  
> figure 2 (unfortunate labelling in PDF). This happens when in both  
> GUI and command-line modes of R. I've shut down other R sessions, and  
> there's no possibility that the file is the wrong file, either.
> 
> Here is my code for creating the PDF file:
> 
>  > pdf("/Users/pchesley/linguistics/research/memory/data/r/figs/ 
> figure_2.pdf") % attached figure_2.pdf
>  > plot(hist(pct$V1, breaks = seq(0, 1, 0.05)), xlab = "% of speakers  
> having seen new word before", ylab = "number of new words", main=" ")
>  > dev.off()
> 
> Can anyone tell me what's going on here? I'm flummoxed, and hoping  
> it's not painfully obvious. :)
> 
> Thanks,
> Paula
> 
> 
> 
> 
> _______________________________________________
> R-lang mailing list
> R-lang at ling.ucsd.edu
> http://pidgin.ucsd.edu/mailman/listinfo/r-lang




More information about the R-lang mailing list