Skip to content

PostScript scatter plot, losing points at RHS

6 messages · Jonathan Campbell, Uwe Ligges, Brian Ripley

#
I'm using the following sequence to plot a scatter plot to PostScript.
Those familiar with the Iris LDA example in MASS will recognise what
I'm at.
All fine except that, compared to the screen plot (apparently
correct), 13 data points are missing on the right hand side.

There is space for them, i.e. the plot is simply blank where they
should be; and extending the height and width makes no difference.

Version 1.9.0  (2004-04-12); running on Linux Fedora Core 2.

TIA,

Jon C.
#
Jonathan Campbell wrote:

            
No, I don't recognise:

- Which edition of MASS?
- I don't see "hulda" nor "hu.ld". Really, do you expect us to read 
through the whole book again to search for some object called "hu.ld"???
- Which Chapter/Section?
- Please specify a reproducible example, as the posting guide ask you to do.
Let me guess: Clipping occured and you may or may not want to rearrange 
spaces or set something like par(xpd=NA).
This version of R is really outdated these days. If my guess mentioned 
above is wrong, please try out R-2.1.0 beta and specify a reproducible 
example.

Uwe Ligges
#
On Apr 9, 2005 4:45 PM, Uwe Ligges <ligges at statistik.uni-dortmund.de> wrote:
My two sentences above were largely irrelevant and the link with MASS
(4th ed. p. 333) was quite oblique. Ignore them, as I would expect
most people would.

However, your suggestion of performing a replicatible experiment is
useful and an exact replica of my problem occurs in it. From MASS 4th
ed. page 304.

data(iris3); ir <- rbind(iris3[,,1], iris3[,,2], iris3[,,3])
ir.species <- factor(c(rep("s", 50), rep("c", 50), rep("v", 50)))
ir.pca <- princomp(log(ir), cor = T)
ir.pc <- predict(ir.pca)
plot(ir.pc[, 1:2], type = "n", xlab = "first principal component",
ylab = "second principal component")

Apparently good plot (to screen). The 150 data points and three
species appear to be there.

Now to PostScript.

postscript("irpca.eps", horizontal=FALSE, onefile=TRUE, height=6,
width=6, pointsize=8, paper="special")
plot(ir.pc[, 1:2], type = "n", xlab = "first principal component",
ylab = "second principal component")
text(ir.pc[,1:2], labels = as.character(ir.species))

Problem. Only 21 "s" points shown -- over on left hand side of the plot.

In my original problem also, the plot was limited 21 points.

TIA,

Jon C.
#
Jonathan Campbell wrote:

            
You forgot
  text(ir.pc[,1:2], labels = as.character(ir.species))
You *really* forgot:
  dev.off()

Everything fine for me, after using dev.off() ...

Uwe Ligges
#
Assuming you did

dev.off()

or quit the session at the end, I cannot reproduce this (even with 1.9.0). 
If you did, it is almost surely a faulty viewer (so check the actual 
file): if not you would have an incomplete plot since you failed to flush 
the output file buffer.
On Sat, 9 Apr 2005, Jonathan Campbell wrote:

            
That plot works too.

  
    
#
On Apr 9, 2005 5:29 PM, Prof Brian Ripley <ripley at stats.ox.ac.uk> wrote:
Nope, I didn't. I assumed (not really thinking at all) that dev.off()
was used merely to switch between display devices.

And when I do, I get the complete plot!

Very many thanks. And to Uwe too, especially for forcing the proper experiment. 

BTW, great software! And a great book (MASS). (I have wasted much of
the last 33 years incompetently rolling my own versions of this
stuff.)

And not bad service either -- particularly for after 5.00pm on a
Saturday afternoon :-)

Thanks again,

Jon C.