here is an example:
x<- 1:10
df<-data.frame(x=x, s1=runif(length(x)),s2=runif(length(x)))
ggplot(melt(df,id="x"),aes(x=x,y=value,colour=variable))+stat_smooth(fill="darkgrey",
size=2, alpha = 0.2)
> --
> You received this message because you are subscribed to the ggplot2 mailing list.
> Please provide a reproducible example: http://gist.github.com/270442
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2
>
c <- ggplot(datax, aes(x=Distance))
c+
stat_smooth(aes(y=Signal1), fill=”darkgrey”, colour=”red”, size=2, alpha = 0.2)+
stat_smooth(aes(y=Signal2), fill=”grey80”, colour=”blue”, size=2, alpha = 0.2)
If it starts to get too complex consider using reshape/melt.
datax2 <- melt(datax, id.vars=Distance)
d <- ggplot(datax, aes(x=Distance, y=value))
d + stat_smooth(aes(colour = variable), size = 2, alpha = 0.2)
Should work...
###############
x
Distance Signal1 Signal2 Signal3
1 -10000 0.03 0.12 0.9
2 -9998 0.03 0.40 0.6
3 -9996 0.02 0.22 0.2
4 -9995 0.02 0.99 0.8
> melt(x, id.vars=Distance)
Error in melt_check(data, id.vars, measure.vars) :
object 'Distance' not found
> melt(x, id.vars="Distance")
Distance variable value
1 -10000 Signal1 0.03
2 -9998 Signal1 0.03
3 -9996 Signal1 0.02
4 -9995 Signal1 0.02
5 -10000 Signal2 0.12
6 -9998 Signal2 0.40
7 -9996 Signal2 0.22
8 -9995 Signal2 0.99
9 -10000 Signal3 0.90
10 -9998 Signal3 0.60
11 -9996 Signal3 0.20
12 -9995 Signal3 0.80
I'm not sure why it didn't work though.
If you run:
#I didn't have "" around the variable name in my example last time
#that may have been the problem
datax2 <- melt(datax, id.vars="Distance")
d <- ggplot(datax, aes(x=Distance, y=value))
d + stat_smooth(aes(colour = variable), size = 2, alpha = 0.2)
What is the error that you get?
Run:
head(datax2, 25)
Does the output look similar to?
Distance variable value
1 -10000 Signal1 0.03
2 -9998 Signal1 0.03
3 -9996 Signal1 0.02
4 -9995 Signal1 0.02
5 -10000 Signal2 0.12
6 -9998 Signal2 0.40
7 -9996 Signal2 0.22
8 -9995 Signal2 0.99
9 -10000 Signal3 0.90
10 -9998 Signal3 0.60
11 -9996 Signal3 0.20
12 -9995 Signal3 0.80
Brandon
B
On Sun, Oct 3, 2010 at 08:36, gireesh bogu <girees...@gmail.com> wrote:
> datax2 <- melt(datax, id.vars="Distance")
>
> d <- ggplot(datax, aes(x=Distance, y=value))
>
> d + stat_smooth(aes(colour = variable), size = 2, alpha = 0.2)
>
> #################################
> datax2 data is looking fine but no output
> it should be this d <- ggplot(datax2, aes(x=Distance, y=value)) ??
>
>
> -G
What about with Takahashi's code?
ggplot(melt(datax,id="Distance"),aes(x=Distance,y=value,colour=variable))+
stat_smooth(fill="darkgrey",size=2, alpha = 0.2)
Brandon
On Sun, Oct 3, 2010 at 08:44, gireesh bogu <girees...@gmail.com> wrote:
> I'm afraid still no output ..
sessionInfo()
and paste the output in here.
On Sun, Oct 3, 2010 at 08:50, gireesh bogu <girees...@gmail.com> wrote:
> It is also same no warning..no output..
The code seems to work for me and Takahasi.
I'm guessing your problem is with your data.
Does your datax2 dataframe look like mine looked?
It should have three columns: Distance, variable, and value.
On Sun, Oct 3, 2010 at 08:54, gireesh bogu <girees...@gmail.com> wrote:
>> sessionInfo()
> R version 2.11.1 (2010-05-31)
> i386-pc-mingw32
> locale:
> [1] LC_COLLATE=English_United States.1252
> [2] LC_CTYPE=English_United States.1252
> [3] LC_MONETARY=English_United States.1252
> [4] LC_NUMERIC=C
> [5] LC_TIME=English_United States.1252
> attached base packages:
> [1] grid stats graphics grDevices utils datasets methods
> [8] base
> other attached packages:
> [1] mgcv_1.6-2 ggplot2_0.8.8 proto_0.3-8 reshape_0.8.3 plyr_1.2.1
> loaded via a namespace (and not attached):
> [1] digest_0.4.2 lattice_0.18-8 Matrix_0.999375-39 nlme_3.1-96
> datax<-read.delim("/Users/bhurr/Desktop/result_skip.txt")
> head(datax)
distance skip_h3k36me3 skip_ptb_clusters ts_h3k36me3 ts_ptb_clusters
1 -999 0.0025 3e-04 0.0049 4e-04
2 -998 0.0025 3e-04 0.0049 3e-04
3 -996 0.0025 3e-04 0.0049 3e-04
4 -994 0.0025 3e-04 0.0049 2e-04
5 -991 0.0025 3e-04 0.0049 1e-04
6 -989 0.0025 3e-04 0.0049 1e-04
> datax2 <- melt(datax, id.vars= "distance")
> head(datax2)
distance variable value
1 -999 skip_h3k36me3 0.0025
2 -998 skip_h3k36me3 0.0025
3 -996 skip_h3k36me3 0.0025
4 -994 skip_h3k36me3 0.0025
5 -991 skip_h3k36me3 0.0025
6 -989 skip_h3k36me3 0.0025
> d <- ggplot(datax2, aes(x=distance, y=value))
>
> d + stat_smooth(aes(colour = variable), size = 2, alpha = 0.2)
Warning messages:
1: Removed 120 rows containing missing values (stat_smooth).
2: Removed 120 rows containing missing values (stat_smooth).
3: Removed 120 rows containing missing values (stat_smooth).
4: Removed 120 rows containing missing values (stat_smooth).
>
On Sun, Oct 3, 2010 at 09:06, gireesh bogu <girees...@gmail.com> wrote:
> Here you go
> thanx
> Gireesh
>
> On Sun, Oct 3, 2010 at 4:05 PM, Brandon Hurr <bhi...@gmail.com> wrote:
>>
>> Can you share your dataset or a subset of it so I can see if I have
>> the same problem?
>>
>> Something seems fishy about this.
>>
>> B
>>
>> On Sun, Oct 3, 2010 at 09:01, gireesh bogu <girees...@gmail.com> wrote:
>> > yes
>> >> datax2[1,]
>> > distance variable value
>> > 1 -999 skip_h3k36me3 0.0025
d <- ggplot(datax2, aes(x=distance, y=value))
>
> d + stat_smooth(aes(colour = variable), fill="darkgrey", alpha = 0.2) + theme_bw()
Warning messages:
1: Removed 120 rows containing missing values (stat_smooth).
2: Removed 120 rows containing missing values (stat_smooth).
3: Removed 120 rows containing missing values (stat_smooth).
4: Removed 120 rows containing missing values (stat_smooth).
On Sun, Oct 3, 2010 at 09:13, gireesh bogu <girees...@gmail.com> wrote:
> thank you. some thing wrong with R. I closed it and ran the same command
> worked fine.
> Thanx for your time!
> really appreciated!
> Gireesh