Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove extra legends in ggplot2 when there are multiple [duplicate]

For example:

require(ggplot2)
require(reshape2)
volcano3d <- melt(volcano) 
names(volcano3d) <- c("x", "y", "z") 
v <- ggplot(volcano3d, aes(x, y, z = z)) 
v1 = v +  stat_contour(aes(colour=..level..,size=..level..)) 

enter image description here

There are two legends on the side, can I remove one of them?

like image 933
qed Avatar asked Sep 14 '26 19:09

qed


1 Answers

See here: http://www.cookbook-r.com/Graphs/Legends_(ggplot2)/

The line you'll need is

v1 = v +  stat_contour(aes(colour=..level..,size=..level..)) + 
scale_colour_continuous(guide=FALSE)

Use scale_size_continuous to turn off the size legend.

like image 88
colcarroll Avatar answered Sep 16 '26 10:09

colcarroll



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!