tsr at stat.washington.edu
2009-Jun-03 08:45 UTC
[Rd] Problems with plot and Quartz device (PR#13744)
Full_Name: Thomas Richardson Version: R 2.9.0 GUI 1.28 Tiger build 32-bit (5395) OS: 10.4.11 Submission from: (NULL) (216.254.15.72) I have encountered a problem with points in scatterplots disappearing in a quartz window when it is re-sized (to make it larger). I am constructing an 8x12 matrix of scatterplots each containing approx 600 points. In order to get them in the window I remove the axes etc., quartz() par(mfrow=c(8,12), mar=c(0,0,0,0), oma=c(0,0,0,0)) for(i in 1:8){ # Row counter for(j in 1:12){ # Col counter plot(rna$red[(rna$row==levels(rna$row[i])&(rna$col==j)], rna$tof[(rna$row==levels(rna$row[i])&(rna$col==j)], xlab="tof",ylab="green",xaxt="n",yaxt="n", ann=FALSE,xlim=c(0,100),ylim=c(0,300),pch=".") } } Here is the problem: how many data points actually appear in the quartz window on my screen is highly sensitive to the width and height specified. If I specify a different width and height for the quartz window e.g. quartz(width=8,height=8), OR if I resize the window with the cursor then points disappear in certain (x-axis) ranges across all the plots in some columns. These bands in which points disappear are the same for all plots in a given column, and can be very wide - making a lot of points disappear. (The visual effect is to make it look as if there are clearly defined vertical white lines going across the scatterplots - though the black lines enclosing each plot are not broken). The problem seems to disappear with other plotting symbols e.g. pch="+" (but then I end up with crowded plots). So I guess it might be related to the "special treatment" of "." described on help(points) ?? --- Value pch="." (equivalently pch = 46) is handled specially. It is a rectangle of side 0.01 inch (scaled by cex). --- I find this behaviour unnerving: the (resized) plots made it look as if there was a lot of structure in the data, but on closer inspection it turned out to be entirely a consequence of the quartz device and plot function! I can't imagine that this behaviour is intended - even if it were intended to suppress points (like some axis labels) - it seems strange that enlarging the window makes points disappear. (I also tried setting dpi=72 in quartz(), but this did not fix the problem). Thanks in advance. Thomas ------------------------------------------------------ sessionInfo() R version 2.9.0 (2009-04-17) i386-apple-darwin8.11.1 locale: en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base
Thomas, rna is not defined in R, can you, please, supply a reproducible example? From your description I think I know roughly what's going on (Quartz attempts to snap rectangles on pixel boundaries to prevent malignant anti-aliasing effects in image plots and this may somehow interact with pch='.' since Quartz has no way of knowing that those rectangles are supposed to be glyphs), but I cannot reproduce it. Thanks, Simon On Jun 3, 2009, at 4:45 , tsr at stat.washington.edu wrote:> Full_Name: Thomas Richardson > Version: R 2.9.0 GUI 1.28 Tiger build 32-bit (5395) > OS: 10.4.11 > Submission from: (NULL) (216.254.15.72) > > > > I have encountered a problem with points in scatterplots > disappearing in a > quartz window when it is re-sized (to make it larger). > > I am constructing an 8x12 matrix of scatterplots each containing > approx 600 > points. > In order to get them in the window I remove the axes etc., > > quartz() > par(mfrow=c(8,12), mar=c(0,0,0,0), oma=c(0,0,0,0)) > for(i in 1:8){ # Row counter > for(j in 1:12){ # Col counter > plot(rna$red[(rna$row==levels(rna$row[i])&(rna$col==j)], > rna$tof[(rna$row==levels(rna$row[i])&(rna$col==j)], > xlab="tof",ylab="green",xaxt="n",yaxt="n", > ann=FALSE,xlim=c(0,100),ylim=c(0,300),pch=".") > } > } > > Here is the problem: how many data points actually appear in the > quartz window > on my screen is highly sensitive to the width and height specified. > If I specify > a different width and height for the quartz window e.g. > quartz(width=8,height=8), OR if I resize the window with the cursor > then points > disappear in certain (x-axis) ranges across all the plots in some > columns. These > bands in which points disappear are the same for all plots in a > given column, > and can be very wide - making a lot of points disappear. > > (The visual effect is to make it look as if there are clearly > defined vertical > white lines going across the scatterplots - though the black lines > enclosing > each plot are not broken). > > The problem seems to disappear with other plotting symbols e.g. > pch="+" (but > then I end up with crowded plots). So I guess it might be related to > the > "special treatment" of "." described on help(points) ?? > --- > Value pch="." (equivalently pch = 46) is handled specially. It is a > rectangle of > side 0.01 inch (scaled by cex). > --- > > I find this behaviour unnerving: the (resized) plots made it look as > if there > was a lot of structure in the data, but on closer inspection it > turned out to be > entirely a consequence of the quartz device and plot function! > > I can't imagine that this behaviour is intended - even if it were > intended to > suppress points (like some axis labels) - it seems strange that > enlarging the > window makes points disappear. (I also tried setting dpi=72 in > quartz(), but > this did not fix the problem). > > Thanks in advance. > > Thomas > > ------------------------------------------------------ > sessionInfo() > R version 2.9.0 (2009-04-17) > i386-apple-darwin8.11.1 > > locale: > en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8 > > attached base packages: > [1] stats graphics grDevices utils datasets methods base > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > >
On Jun 3, 2009, at 4:45 , tsr at stat.washington.edu wrote:> Full_Name: Thomas Richardson > Version: R 2.9.0 GUI 1.28 Tiger build 32-bit (5395) > OS: 10.4.11 > Submission from: (NULL) (216.254.15.72) > > > > I have encountered a problem with points in scatterplots > disappearing in a > quartz window when it is re-sized (to make it larger). > > I am constructing an 8x12 matrix of scatterplots each containing > approx 600 > points. > In order to get them in the window I remove the axes etc., > > quartz() > par(mfrow=c(8,12), mar=c(0,0,0,0), oma=c(0,0,0,0)) > for(i in 1:8){ # Row counter > for(j in 1:12){ # Col counter > plot(rna$red[(rna$row==levels(rna$row[i])&(rna$col==j)], > rna$tof[(rna$row==levels(rna$row[i])&(rna$col==j)], > xlab="tof",ylab="green",xaxt="n",yaxt="n", > ann=FALSE,xlim=c(0,100),ylim=c(0,300),pch=".") > } > } > > Here is the problem: how many data points actually appear in the > quartz window > on my screen is highly sensitive to the width and height specified. > If I specify > a different width and height for the quartz window e.g. > quartz(width=8,height=8), OR if I resize the window with the cursor > then points > disappear in certain (x-axis) ranges across all the plots in some > columns. These > bands in which points disappear are the same for all plots in a > given column, > and can be very wide - making a lot of points disappear. > > (The visual effect is to make it look as if there are clearly > defined vertical > white lines going across the scatterplots - though the black lines > enclosing > each plot are not broken). > > The problem seems to disappear with other plotting symbols e.g. > pch="+" (but > then I end up with crowded plots).BTW: you may want to use something like pch=19, cex=0.1 (and maybe add some alpha to get a quick density estimation). Cheers, S> So I guess it might be related to the > "special treatment" of "." described on help(points) ?? > --- > Value pch="." (equivalently pch = 46) is handled specially. It is a > rectangle of > side 0.01 inch (scaled by cex). > --- > > I find this behaviour unnerving: the (resized) plots made it look as > if there > was a lot of structure in the data, but on closer inspection it > turned out to be > entirely a consequence of the quartz device and plot function! > > I can't imagine that this behaviour is intended - even if it were > intended to > suppress points (like some axis labels) - it seems strange that > enlarging the > window makes points disappear. (I also tried setting dpi=72 in > quartz(), but > this did not fix the problem). > > Thanks in advance. > > Thomas > > ------------------------------------------------------ > sessionInfo() > R version 2.9.0 (2009-04-17) > i386-apple-darwin8.11.1 > > locale: > en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8 > > attached base packages: > [1] stats graphics grDevices utils datasets methods base > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > >