[R] ggplot with geom_tile
Pelt van, Saskia (KNMI)
saskia.van.pelt at knmi.nl
Fri Dec 9 13:47:41 CET 2011
Dear Frederic,
No this was not the problem, the problem are horizontal and vertical white lines in the figure. But the problem is gone when I save the figure and reopen it (in another program), so I think the problem is only with my direct plot outputs.
Thanks for your help.
Kind regards,
Saskia
________________________________
From: Frederic Andrieu [mailto:fandrieu at mango-solutions.com]
Sent: Fri 09/12/2011 12:43
To: Pelt van, Saskia (KNMI)
Cc: r-help at r-project.org; Hiemstra, Paul (KNMI)
Subject: RE: [R] ggplot with geom_tile
Dear Saskia,
If you mean the grid lines around the edge then they can be removed by using the following:
p <- ggplot(tot, aes(x=temp, y=precip,group=dis))
p+geom_tile(aes(fill=dis)) + scale_fill_gradientn(colours=cols) +
scale_x_continuous(expand = c(0,0)) +
scale_y_continuous(expand = c(0,0))
I hope this helps
I remain at your disposal should you have any questions.
Best regards,
Frederic Andrieu
M: +44(0)07813 526 123
T: +44 (0)1249 766 801
F: +44 (0)1249 767 707
www.mango-solutions.com
Unit 2 Greenways Business Park
Bellinger Close
Chippenham
Wilts
SN15 1BN
UK
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Paul Hiemstra
Sent: 09 December 2011 11:23
To: Pelt van, Saskia (KNMI)
Cc: r-help at r-project.org
Subject: Re: [R] ggplot with geom_tile
Dear Saskia,
Thank you for the reproducible example, that helps a lot. I pasted you
code into R and got a perfectly fine image. You need to provide us with
your sessionInfo(). Mine is listed at the end of the mail. I seem to
remember having this problem with R 2.12. Therefore updating R might be
a good option.
hope this helps,
Paul
> sessionInfo()
R version 2.13.0
(2011-04-13)
Platform: i686-pc-linux-gnu
(32-bit)
locale:
[1] LC_CTYPE=en_US.utf8
LC_NUMERIC=C
[3] LC_TIME=en_US.utf8
LC_COLLATE=en_US.utf8
[5] LC_MONETARY=C
LC_MESSAGES=en_US.utf8
[7] LC_PAPER=en_US.utf8
LC_NAME=C
[9] LC_ADDRESS=C
LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.utf8
LC_IDENTIFICATION=C
attached base
packages:
[1] grid stats graphics grDevices utils datasets
methods
[8]
base
other attached
packages:
[1] ggplot2_0.8.9 proto_0.3-9.2 reshape_0.8.4 plyr_1.6
fortunes_1.4-2
loaded via a namespace (and not
attached):
[1]
digest_0.5.1
On 12/09/2011 10:33 AM, Pelt van, Saskia (KNMI) wrote:
> Dear R-users,
>
> I am trying to make a plot with ggplot-geom_tile(), but cannot remove some unwanted (white) lines through my plot.
>
> Below a reproducible example:
>
> #####
> library(ggplot2)
> tot=as.data.frame(rep(seq(-50,50,5),each=21))
> names(tot)="precip"
> temp=rep(seq(-5,5,0.5),21)
> tot$temp=temp
>
> disc=array(dim=c(21,21))
> for(i in 1:21){
> for(y in 1:21){
> temp<- rev(seq(10000+((i-1)*500),12000+((i-1)*500),100))
> disc[i,y]=temp[y]
> }}
>
> disc1=t(disc)
> bla=as.vector(disc1)
> tot$dis=bla
>
> cols=c("darkred"," white"," darkblue")
>
> p <- ggplot(tot, aes(x=temp, y=precip,group=dis))
> p+geom_tile(aes(fill=dis)) + scale_fill_gradientn(colours=cols)
> ###
>
> This creates the plot that I want, but with white horizontal and vertical lines that I do not need. I have tried different things, but have not found the solution. Can you help me with this problem?
>
> Kind regards,
>
> Saskia van Pelt
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
--
Paul Hiemstra, Ph.D.
Global Climate Division
Royal Netherlands Meteorological Institute (KNMI)
Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39
P.O. Box 201 | 3730 AE | De Bilt
tel: +31 30 2206 494
http://intamap.geo.uu.nl/~paul
http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770
______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
LEGAL NOTICE\ This message is intended for the use of th...{{dropped:12}}
More information about the R-help
mailing list