Could we make filled.contour() more suitable for PDF viewers?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Could we make filled.contour() more suitable for PDF viewers?

Abby Spurdle
Note that I sent this to r-devel, yesterday.
However, it didn't appear on the mailing list.
So, I'm resending it.

Today, I plotted the following:
> filled.contour (,,z, color.palette=terrain.colors)

It looked OK, in R.
However, when I created a PDF document, the plot (and other similar plots)
had grid (and other) lines in it, that shouldn't be there.
Note that this problem is more obvious with terrain.colors than cm.colors,
which is the default.

I found this in the help file for the pdf() function:
"the problem is much more likely to be in your viewer than in R... apparent
grids on image plots (turn off graphics anti-aliasing in your viewer if you
can)..."

Later, I found (in Acrobat Reader XI) the following option:
Edit > Preferences... > Page Display > Smooth line art

I unticked this option and it corrected the problem.

In principle, this is a problem with the PDF viewer, and not R.
However, it would be better if filled.contour() didn't have this result.
And I've decided not to use filled.contour() because of this.

Note that filled.contour() calls .filled.contour(), which calls:
+ .External.graphics(C_filledcontour, x, y, z, levels, col)

Also note that I had a similar plot with a similar problem.
It contained the following line:
+ polygon (xsub, ysub, border=NA, col=colstr)
But the problem was corrected after changing it to:
+ polygon (xsub, ysub, border=colstr, col=colstr)

I'm assuming that an equally simple change to C_filledcontour, could
correct the problem above.

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: [FORGED] Could we make filled.contour() more suitable for PDF viewers?

Paul Murrell-2
Hi

One problem with that solution is that it is drawing the wrong thing.
The border of the polygonal regions is drawn centred on the edge of the
region, so it overlaps adjacent regions.  The following code exaggerates
the problem ...

pdf("demo.pdf")
dev.control("enable")
image(x=1:2, y=1:2, z=matrix(1:4, ncol=2))
library(gridGraphics)
grid.echo()
rect <- grid.get("rect", grep=TRUE)
grid.edit("rect", grep=TRUE,
           gp=gpar(col=adjustcolor(1:4, alpha=.5), lwd=10,
                   fill=adjustcolor(rect$gp$fill, alpha=.5)))
dev.off()

Paul

On 16/03/19 10:43 AM, Abs Spurdle wrote:

> Note that I sent this to r-devel, yesterday.
> However, it didn't appear on the mailing list.
> So, I'm resending it.
>
> Today, I plotted the following:
>> filled.contour (,,z, color.palette=terrain.colors)
>
> It looked OK, in R.
> However, when I created a PDF document, the plot (and other similar plots)
> had grid (and other) lines in it, that shouldn't be there.
> Note that this problem is more obvious with terrain.colors than cm.colors,
> which is the default.
>
> I found this in the help file for the pdf() function:
> "the problem is much more likely to be in your viewer than in R... apparent
> grids on image plots (turn off graphics anti-aliasing in your viewer if you
> can)..."
>
> Later, I found (in Acrobat Reader XI) the following option:
> Edit > Preferences... > Page Display > Smooth line art
>
> I unticked this option and it corrected the problem.
>
> In principle, this is a problem with the PDF viewer, and not R.
> However, it would be better if filled.contour() didn't have this result.
> And I've decided not to use filled.contour() because of this.
>
> Note that filled.contour() calls .filled.contour(), which calls:
> + .External.graphics(C_filledcontour, x, y, z, levels, col)
>
> Also note that I had a similar plot with a similar problem.
> It contained the following line:
> + polygon (xsub, ysub, border=NA, col=colstr)
> But the problem was corrected after changing it to:
> + polygon (xsub, ysub, border=colstr, col=colstr)
>
> I'm assuming that an equally simple change to C_filledcontour, could
> correct the problem above.
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

--
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
[hidden email]
http://www.stat.auckland.ac.nz/~paul/

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel