Grey grid on image after update R 2.9.0 ?

20 views
Skip to first unread message

Angel Berihuete Macías

unread,
May 10, 2009, 4:06:13 AM5/10/09
to ggplot2, baptiste auguie, Juliet Hannah
Dear all,

Yesterday, baptiste and Juliet resolved me a problem about align two
(or more) plots on a page (http://ggplot2.wik.is/Align_two_plots_on_a_page
). I have upgraded to R 2.9.0 (below I put my new R.Version). Now,
when I plot the image, there is a grey grid on top (see Image
attached). How can I erase that grid?

Thank you,

Angel.

Imagen.png

baptiste auguie

unread,
May 10, 2009, 5:37:24 AM5/10/09
to Angel Berihuete Macías, ggplot2
Hi,

it could be one of several things i suppose:

- visual artifact of the image viewer (such Moiré is typical of images
displayed in pdf viewers) --- but here you seem to use quartz so it
should not happen, i think

- you have set the colour of the tiles to the grey value (or perhaps
NA as grey is the default background). Try to set colour = "your
variable" in addition to fill = "your variable" in the aes() call.
Actually, after testing on a dummy example, it seems that you'd be
better off not specifying colour at all in aes() for some reason that
I don't really understand. Try both, then :). And it may be that the
type of your colour variable matters (factor or numeric?...)

- your data has some weird pattern in it (in which case, try to give a
reproducible example), at least str("your data.frame")

- perhaps something else

I'm guessing it's # 2

HTH,

baptiste

On Sun, May 10, 2009 at 10:06 AM, Angel Berihuete Macías
<an...@alfomega.es> wrote:
> Dear all,
>
> Yesterday, baptiste  and Juliet resolved me a problem about align two (or

> more) plots on a page (http://ggplot2.wik.is/Align_two_plots_on_a_page). I


> have upgraded to R 2.9.0 (below I put my new R.Version). Now, when I plot
> the image, there is a grey grid on top (see Image attached). How can I erase
> that grid?
>
> Thank you,
>
> Angel.
>
>
>

> $platform
> [1] "powerpc-apple-darwin8.11.1"
>
> $arch
> [1] "powerpc"
>
> $os
> [1] "darwin8.11.1"
>
> $system
> [1] "powerpc, darwin8.11.1"
>
> $status
> [1] ""
>
> $major
> [1] "2"
>
> $minor
> [1] "9.0"
>
> $year
> [1] "2009"
>
> $month
> [1] "04"
>
> $day
> [1] "17"
>
> $`svn rev`
> [1] "48333"
>
> $language
> [1] "R"
>
> $version.string
> [1] "R version 2.9.0 (2009-04-17)"
>
>
>
>

--

_____________________________

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag
______________________________

Angel Berihuete Macías

unread,
May 11, 2009, 1:31:30 AM5/11/09
to baptiste auguie, ggplot2, hadley wickham
Thanks for your response baptiste. I think the problem is
expand.grid() function. Please try this.

# ---------------------------
# Everything is all rigth
# ---------------------------

data<- t(volcano)[ncol(volcano):1,]

ggplot(melt(data), aes(x=X1,y=X2,fill=value))+geom_tile()


# -------------------------------
# Light grey lines appear
# -------------------------------

x<-1:87
y<-1:61
xy<-expand.grid(x=x,y=y)
d1 <- data.frame(x=x, y=rnorm(length(x)))
d2<-data.frame(x=xy$x,y=xy$y,z=as.vector(t(data)))

d1$panel <- "a"
d2$panel <- "c"

d1$z <- d1$x

d <- rbind(d1,d2)

p <- ggplot(data=d, mapping=aes(x = x,y = y))
p <- p + facet_grid(panel~.,scale="free")
p <- p + layer(data=d1, geom=c("line"), stat = "identity")
p <- p + layer(data=d2, mapping=aes(colour=z, fill=z), geom=c("tile"),
stat = "identity")

p

# ---------------------------------------------------------

baptiste auguie

unread,
May 11, 2009, 4:11:41 AM5/11/09
to Angel Berihuete Macías, ggplot2
The problem seems to arise when you specify both colour and fill in
the aes (last line). It has nothing to do with the data or
expand.grid, as can be seen in this minimal example,


d<- t(volcano)[ncol(volcano):1,]

p <-
ggplot(melt(d), aes(x=X1,y=X2,fill=value))+geom_tile()

p # correct appearance
p + aes(colour=value) # 'greyish' grid

I'm not sure why this behaviour is observed, it may have something to
do with the linewidth of the squares that is slightly too thin to
merge the neighbouring elements together.

Anyway, if you don't need it, just remove colour in aes().

HTH,

baptiste






On Mon, May 11, 2009 at 7:31 AM, Angel Berihuete Macías

Angel Berihuete Macías

unread,
May 11, 2009, 6:51:14 AM5/11/09
to baptiste auguie, ggplot2
Ok, now the plot is perfect!

Thank you very much baptiste.

Angel.

Angel Berihuete Macías

unread,
May 12, 2009, 8:18:28 AM5/12/09
to ggplot2, hadley wickham, baptiste auguie
Well, that is incredible. I was so happy yesterday but... When I plot
my graphics, again the lines appear on the plot, but if I resize the
image the number of the lines changes.

I have not idea what is happening. Somethig about quartz device? I
need your help again.

Thanks,


Angel.


Imagen 1.png
Imagen 2.png

Juliet Hannah

unread,
May 12, 2009, 9:25:10 AM5/12/09
to Angel Berihuete Macías, ggplot2
Hi Angel,

Are you resizing on screen? Try using

ggsave("myplot.pdf")

directly, and adjust the size parameters with options for the pdf device.

Regards,

Juliet
>> --~--~---------~--~----~------------~-------~--~----~
>> You received this message because you are subscribed to the ggplot2
>> mailing list.
>> To post to this group, send email to ggp...@googlegroups.com
>> To unsubscribe from this group, send email to
>> ggplot2+u...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/ggplot2
>> -~----------~----~----~----~------~----~------~--~---
>>
>
>
>
Reply all
Reply to author
Forward
0 new messages