R : gpplot2 breaks and labels

109 views
Skip to first unread message

Abdullah Sahyoun

unread,
Feb 6, 2014, 5:14:54 AM2/6/14
to ggp...@googlegroups.com
Hi,

Im trying to plot some data using ggplot2 and stat_contout, but im having a problem which im not able to understand.

the plotting is something like that :

dataf$pval
.d <- cut(dataf$pvalue, breaks=c(min(dataf$X),0.05,Inf), labels=c("min","0.05"), right = FALSE) pl <-ggplot(dataf) + geom_tile(aes(fill=C,A,B)) + stat_contour(breaks = c(min(dataf$X),0.05), aes(x=A,y=B,z=pvalue,colour = ..level..)) + scale_colour_gradient2(low="black",mid="black",high="green", labels=paste(levels(dataf$pval.d),table(dataf$pval.d)), name="\n P-value \n")


but the plot is giving me this error:

Error in scale_labels.continuous(scale, breaks) :
  Breaks and labels are different lengths


eventhough when i print the output of a part of the summary of the plot:

> summary(pl)

mapping: x = A y = B z = pvalue colour = ..level..
geom_path: na.rm = FALSE
stat_contour: breaks = c(0.0231001371742112, 0.05)
position_identity: (width = NULL, height = NULL)


the breaks length seems to be of lenght = 2


and the same applies when i output

> paste(levels(dataf$pval.d),table(dataf$pval.d))

[1] "min 0" "0.05 10"



NOTE: if i remove the breaks from stat_contour or the labels from
scale_colour_gradient2, the plots works fine.

any help would be appreciated.


Ista Zahn

unread,
Feb 8, 2014, 1:11:44 PM2/8/14
to Abdullah Sahyoun, ggplot2
Hi,

You will probably have better luck getting an answer if you post a
reproducible example,

Best,
Ista
> --
> --
> You received this message because you are subscribed to the ggplot2 mailing
> list.
> Please provide a reproducible example:
> https://github.com/hadley/devtools/wiki/Reproducibility
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2
>
> ---
> You received this message because you are subscribed to the Google Groups
> "ggplot2" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ggplot2+u...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
Reply all
Reply to author
Forward
0 new messages