title: R : ggplot2 breaks and label
body: <p>I have a problem with R ggplot2.</p>
  
  <p>Im getting this error:</p>
  
  <pre><code>Error in scale_labels.continuous(scale, breaks) : 
    Breaks and labels are different lengths
  </code></pre>
  
  <p>even though im sure that breaks and labels are the same length.</p>
  
  <p>is there anyway to debug the plots (i.e check the plot variable for breaks and labels to check where is the error)</p>
  
  <p>the code im using is:</p>
  
  <pre><code>dataf$pval.d &lt;- cut(dataf$pvalue, breaks=c(min(dataf$X),0.05,Inf), 
                      labels=c("min","0.05"), right = FALSE)
  
  pl &lt;-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")
  </code></pre>
  
  <p>a sample of the data frame <code>dataf</code> is something like that:</p>
  
  <pre><code>    A  B         C      pval
  1   8  4 0.6714801 0.3138729
  2   9  9 0.6373763 0.1402027
  3   5  6 0.6695279 0.3426810
  4  10  7 0.6338043 0.1722161
  5   2  3 0.6692842 0.3301052
  6   1  1 0.6728664 0.5777641
  7   6  2 0.6608868 0.2637952
  8   3 10 0.6721009 0.6584530
  9   7  8 0.6338043 0.7839811
  10  4  5 0.6728818 0.5045481
  </code></pre>
  
  <p>the output of:</p>
  
  <pre><code>&gt; paste(levels(dataf$pval.d),table(dataf$pval.d))
  [1] "min 0"   "0.05 10"
  </code></pre>
  
  <p>as you can see, the labels and breaks are of the same length, but maybe im making something wrong which im not aware about?</p>