1

I am using ggplot to plot a scatter plot and add contour lines to it. I did get contour lines but it does not fill my entire data.

ggplot(training_validation, aes(x=training_mean, y=validation_mean, color = threshold)) +
  geom_point() +
  scale_color_manual(values=c("red", "gold","gray79","midnightblue")) +
  theme( panel.grid.major = element_blank(), panel.grid.minor = element_blank()) +
  xlab("Mean Training AUC") +
  ylab("Mean Validation AUC")  + 
  stat_density2d(aes(fill=..level..,alpha=..level..), geom='polygon',colour='black') +
  scale_fill_continuous(low="green",high="red") + 
  geom_smooth(method=lm,linetype=2,colour="red",se=F) +
  guides(alpha="none") 

This is what I get - enter image description here

I want the contour lines to fill the entire plot. How can I do it?

Nate
  • 10,361
  • 3
  • 33
  • 40
Sia
  • 43
  • 5
  • 2
    Probably something like `scale_fill_gradient(low="green",high="red", limits=c(0,30))`. – eipi10 Nov 15 '17 at 19:20
  • please provide a [minimal example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – Nate Nov 15 '17 at 19:25
  • @eipi10 it still gives me the same plot – Sia Nov 15 '17 at 20:16
  • Where do you want more lines? It looks like the `..level..` value beyond the last contour line would be very low already. – Z.Lin Nov 16 '17 at 10:54

0 Answers0