How to remove the crossbar legends ggplot geom_bar?

I was looking for a WEB to remove the crossbars in the legend of ggplot bottom tablets. But no success. Could you help me fix this. Below is the "temp" data and the code I'm using. Could you also tell me how to use patterns in bars? Thanks.

temp: type var value A k1 20 A l1 30 B k1 10 B l1 15 ggplot(temp,aes(type, value)) + geom_bar(stat="identity", aes(group=var, fill=type, facets=var),colour="blue1", position="identity") + facet_grid(.~var) + theme_bw() 

enter image description here

+4
source share
1 answer

The only way to do this is to make two geom_bar layers, one with blue, but without legend, and one without blue, but with legend:

 ggplot(temp,aes(type, value)) + geom_bar(stat="identity", aes(group=var, fill=type, facets=var),color = "blue1", position="identity",legend = "none") + geom_bar(stat="identity", aes(group=var, fill=type, facets=var), position="identity") + facet_grid(.~var) + theme_bw() 

enter image description here

I doubt a little that the reason for this is not simpler, because the author of the package, as a design solution, wants the legends to match what is on the layer exactly. In most cases, you are probably very pleased with this behavior, but accidentally awkward comes with great convenience.

+7
source

All Articles