[R] dev.copy legend problem

2005-11-17 Thread Florence Combes
Dear all,

We are facing this problem for long, and so ask for your help.

We are plotting 2 graphs in a postscript device (left part -layout
function-), and the common legend for these graphs on the right part.
The legend in the postscript device looks ok: this is color lines with
numbers on the right (6 columns) , see the code below:

> nblock<-c(1:48)
> leg<-paste(c(1:npin)," ",sep=" ")
> legend(0,19,legend = leg, col=rainbow(nblock), lty=1,
merge=TRUE,ncol=6,bty="n",cex=0.6)

The problem we are facing is that we dev.copy to a pdf device and then, the
legend doesn't look the same: numbers overlap a little lines.

Has someone already encountered such a thing ?

Any help apreciated, thanks a lot.

Florence.


R 2.1.0 on a Linux Debian.

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] dev.copy legend problem

2005-11-17 Thread Marc Schwartz (via MN)
On Thu, 2005-11-17 at 17:03 +0100, Florence Combes wrote:
> Dear all,
> 
> We are facing this problem for long, and so ask for your help.
> 
> We are plotting 2 graphs in a postscript device (left part -layout
> function-), and the common legend for these graphs on the right part.
> The legend in the postscript device looks ok: this is color lines with
> numbers on the right (6 columns) , see the code below:
> 
> > nblock<-c(1:48)
> > leg<-paste(c(1:npin)," ",sep=" ")
> > legend(0,19,legend = leg, col=rainbow(nblock), lty=1,
> merge=TRUE,ncol=6,bty="n",cex=0.6)
> 
> The problem we are facing is that we dev.copy to a pdf device and then, the
> legend doesn't look the same: numbers overlap a little lines.

The problem with using dev.copy() is that it can result in slightly (or
notably) different plotting characteristics, which are device dependent.

A plot that is viewed on the screen, for example, may or may not (most
likely not) look the same when created using the same code to a
postscript device or a pdf device. This can be further exacerbated if
the plot device dimensions and pointsizes are not explicitly defined, as
"device shrinkage" may occur. I suspect that this is what you are
experiencing.

If you want to end up with a PDF plot, use pdf() and set the various
plotting parameters (ie. font size, etc.) based upon what you see there,
not what you see on the screen or in another device.

One other possibility, just to throw it out there since you are on
Linux, is to use ps2pdf from a console to convert the PS file to PDF.
This uses Ghostscript to do the conversion and will generally work well,
but testing with your particular plot, given possible issues with fonts,
etc. would still be a good idea. See 'man ps2pdf' for more information.

> Has someone already encountered such a thing ?
> 
> Any help apreciated, thanks a lot.
> 
> Florence.
> 
> 
> R 2.1.0 on a Linux Debian.

Have not been able to get your SysAdmin to upgrade you yet?

:-)

HTH,

Marc Schwartz

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] dev.copy legend problem

2005-11-17 Thread Prof Brian Ripley
That's why we recommend that you do not use dev.copy but replot on the 
target device.

Different devices have different fonts and font metrics, and so the plot 
as laid out for one will almost always not be right for the other.

According to the help page for dev.copy you cannot by default copy from 
postscript() to pdf().  Is that really what you are doing?  It seems to 
work for me once I enable copying, as those two devices do share fonts.

On Thu, 17 Nov 2005, Florence Combes wrote:

> We are facing this problem for long, and so ask for your help.
>
> We are plotting 2 graphs in a postscript device (left part -layout
> function-), and the common legend for these graphs on the right part.
> The legend in the postscript device looks ok: this is color lines with
> numbers on the right (6 columns) , see the code below:
>
>> nblock<-c(1:48)
>> leg<-paste(c(1:npin)," ",sep=" ")
>> legend(0,19,legend = leg, col=rainbow(nblock), lty=1,
> merge=TRUE,ncol=6,bty="n",cex=0.6)
>
> The problem we are facing is that we dev.copy to a pdf device and then, the
> legend doesn't look the same: numbers overlap a little lines.
>
> Has someone already encountered such a thing ?

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] dev.copy legend problem

2005-11-18 Thread Florence Combes
Thanks for the answer.

>
> >
> > The problem we are facing is that we dev.copy to a pdf device and then,
> the
> > legend doesn't look the same: numbers overlap a little lines.
>
> I suspect that this is what you are
> experiencing.


yes it seems to be

If you want to end up with a PDF plot, use pdf() and set the various
> plotting parameters (ie. font size, etc.) based upon what you see there,
> not what you see on the screen or in another device.


we plot the graphs on the postscript device (because on the server I work
X11 is unfortunately not available), and after we copy from postscript
device to both pdf (dev.copy) and bitmap (dev2bitmap) device (.png file at
the end).
So the graphs look OK on png image but not on the pdf ; I will try to set
parameters on pdf()

One other possibility, just to throw it out there since you are on
> Linux, is to use ps2pdf from a console to convert the PS file to PDF.


Thanks for this, I already used 'ps2pdf' before, but in this way I can't
because:
- I do several graphics in the script, each of them is "drawn" on the
postscript device, copied to bitmap and pdf, then the postscript device is
shut down but not the pdf one, which presents all the graphics in one file
(several pages) at the end.
- the script has to be a "cross platform" one...


Thanks again, I try settings on pdf() and tell you,

Florence.

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] dev.copy legend problem

2005-11-18 Thread Florence Combes
On 11/17/05, Prof Brian Ripley <[EMAIL PROTECTED]> wrote:
>
> That's why we recommend that you do not use dev.copy but replot on the
> target device.


as I plot the graph in the postscript device, and then want to save it into
both pdf and png files, I prefer using dev.copy because it allows me to
avoid replot the same graph two times.


>
> According to the help page for dev.copy you cannot by default copy from
> postscript() to pdf(). Is that really what you are doing? It seems to
> work for me once I enable copying, as those two devices do share fonts.


yes, you are right, we do:

> dev.control("enable")

Thanks,
Florence.



On Thu, 17 Nov 2005, Florence Combes wrote:
>
> > We are facing this problem for long, and so ask for your help.
> >
> > We are plotting 2 graphs in a postscript device (left part -layout
> > function-), and the common legend for these graphs on the right part.
> > The legend in the postscript device looks ok: this is color lines with
> > numbers on the right (6 columns) , see the code below:
> >
> >> nblock<-c(1:48)
> >> leg<-paste(c(1:npin)," ",sep=" ")
> >> legend(0,19,legend = leg, col=rainbow(nblock), lty=1,
> > merge=TRUE,ncol=6,bty="n",cex=0.6)
> >
> > The problem we are facing is that we dev.copy to a pdf device and then,
> the
> > legend doesn't look the same: numbers overlap a little lines.
> >
> > Has someone already encountered such a thing ?
>
> --
> Brian D. Ripley, [EMAIL PROTECTED]
> Professor of Applied Statistics, 
> http://www.stats.ox.ac.uk/~ripley/
> University of Oxford, Tel: +44 1865 272861 (self)
> 1 South Parks Road, +44 1865 272866 (PA)
> Oxford OX1 3TG, UK Fax: +44 1865 272595
>

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html