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.