Bug 14583 - Points are not guaranteed to plot
Points are not guaranteed to plot
Status: RESOLVED FIXED
Product: R
Classification: Unclassified
Component: Graphics
R 2.13.0
ix86 (32-bit) Windows 32-bit
: P5 normal
Assigned To: R-core
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-05-13 22:07 UTC by Max Robinson
Modified: 2011-05-14 12:13 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Max Robinson 2011-05-13 22:07:27 UTC
Overview:  Points visible in one plot disappear in a plot shifted 1 unit in the x direction, despite the points still being located well within the plot area.

Steps to Reproduce:

On my system (Windows XP SP3, monitor 1680 x 1050 pixels, 16 bit color), with the console and graphics windows tiled vertically, the code shown below shows fewer points in the plot to the left than the plot to the right, despite the fact that all the points are well within the plot boundaries for both plots.  Maximizing the size of the graphics window, more points appear in the plot to the left (To me, this fact suggests this bug may be very sensitive to the precise system hardware, software, settings, window size, etc.).  I noticed this behavior under version 2.12, then updated (today, 13 Mar 2011) to the latest version; the behavior is the same.  Code:

par(mfrow=c(2,2),pch='.')
x <- c(163.1196,163.1165,163.1205,
       163.1204,163.1189,163.1195,
       163.1186,163.1189,163.1147,163.1186)

y <- c(1560,598,1333,1135,1056,824,841,910,3809,1135)

plot(x,y,xlim=c(150,180))
plot(x,y,xlim=c(150,180)+1)

Actual results:

When the graphics window is tiled next to the console window, 0 points appear in the plot to the left; 5 points appear in the plot to the right.  When the console window is maximized, 9 points (two appear as vertically adjacent pixels, so it looks like 8, one of which is slightly taller) appear in each plot.

Expected results:

(1) The same number of points should be visible in both plots.
(2) For a set of points that have equivalent x positions, the number of points that are visible should not change when only the horizontal resolution of the graphics window is changed.
(3) When pch='.', all data points within the visible area of a plot should cause at least one pixel to be rendered in the foreground color.

Build Date and Platform:

According to the General tab on System Properties, my version of Windows is:
   Microsoft Windows XP, Professional, Version 2002, Service Pack 3

According to the R "About" option, my version of R is:
   R version 2.13.0 (2011-04-13)

However, as I explained above I first encountered this bug on version 2.12, which is no longer installed on my machine.

Additional information:

After saving the graphics window to a .eps file and converting that file to .pdf, at 4x magnification in Adobe Reader X, 9 dots (two of which overlap) are visible in each plot.  This is consistent with the graphics window when maximized.
Comment 1 Max Robinson 2011-05-13 23:01:53 UTC
(In reply to comment #0)

Under Steps to Reproduce it should read "today, 13 May 2011", not March.
Comment 2 Duncan Murdoch 2011-05-14 12:13:28 UTC
I think I've found and fixed where the rounding was occurring.  I won't be able to commit the changes until tomorrow or Monday, but I think this is fixed.
Comment 3 Duncan Murdoch 2011-05-14 15:35:41 UTC
On 11-05-13 5:07 PM, r-bugs@r-project.org wrote:
> https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=14583
>
>             Summary: Points are not guaranteed to plot
>             Product: R
>             Version: R 2.13.0
>            Platform: ix86 (32-bit)
>          OS/Version: Windows 32-bit
>              Status: NEW
>            Severity: normal
>            Priority: P5
>           Component: Graphics
>          AssignedTo: R-core@R-project.org
>          ReportedBy: max.robinson@systemsbiology.org
>     Estimated Hours: 0.0
>
>
> Overview:  Points visible in one plot disappear in a plot shifted 1 unit in the
> x direction, despite the points still being located well within the plot area.


I can see the effect, but I'm not sure where it arises.
A simple workaround is to use a larger cex:  if the dot is larger than 
cex=1, it seems to display consistently.

I haven't tracked this down, but I suspect it's a rounding error.  Dots 
are displayed as 1x1 squares. At some point floating point values are 
converted to integers, and for some locations, the limits of the square 
end up equal, rather than differing by 1 pixel.

The Windows GDI call takes integer input, so the rounding is probably 
happening somewhere in our code.

Duncan Murdoch

>
> Steps to Reproduce:
>
> On my system (Windows XP SP3, monitor 1680 x 1050 pixels, 16 bit color), with
> the console and graphics windows tiled vertically, the code shown below shows
> fewer points in the plot to the left than the plot to the right, despite the
> fact that all the points are well within the plot boundaries for both plots.
> Maximizing the size of the graphics window, more points appear in the plot to
> the left (To me, this fact suggests this bug may be very sensitive to the
> precise system hardware, software, settings, window size, etc.).  I noticed
> this behavior under version 2.12, then updated (today, 13 Mar 2011) to the
> latest version; the behavior is the same.  Code:
>
> par(mfrow=c(2,2),pch='.')
> x<- c(163.1196,163.1165,163.1205,
>         163.1204,163.1189,163.1195,
>         163.1186,163.1189,163.1147,163.1186)
>
> y<- c(1560,598,1333,1135,1056,824,841,910,3809,1135)
>
> plot(x,y,xlim=c(150,180))
> plot(x,y,xlim=c(150,180)+1)
>
> Actual results:
>
> When the graphics window is tiled next to the console window, 0 points appear
> in the plot to the left; 5 points appear in the plot to the right.  When the
> console window is maximized, 9 points (two appear as vertically adjacent
> pixels, so it looks like 8, one of which is slightly taller) appear in each
> plot.
>
> Expected results:
>
> (1) The same number of points should be visible in both plots.
> (2) For a set of points that have equivalent x positions, the number of points
> that are visible should not change when only the horizontal resolution of the
> graphics window is changed.
> (3) When pch='.', all data points within the visible area of a plot should
> cause at least one pixel to be rendered in the foreground color.
>
> Build Date and Platform:
>
> According to the General tab on System Properties, my version of Windows is:
>     Microsoft Windows XP, Professional, Version 2002, Service Pack 3
>
> According to the R "About" option, my version of R is:
>     R version 2.13.0 (2011-04-13)
>
> However, as I explained above I first encountered this bug on version 2.12,
> which is no longer installed on my machine.
>
> Additional information:
>
> After saving the graphics window to a .eps file and converting that file to
> .pdf, at 4x magnification in Adobe Reader X, 9 dots (two of which overlap) are
> visible in each plot.  This is consistent with the graphics window when
> maximized.
>