简体   繁体   中英

How to add the legend for the barchart superimposed onto a ggplot2 map (annotation_custom)?

In: "How to plot barchart onto ggplot2 map" Inscaven has proposed an efficient way for adding barplot onto a map without using subplot library.

But how adding the legend for any barplot since theme(legend.position = "topright") does not work ?

If you want to place the legend in the top right corner, instead of "topright" you can specify a legend position as coordinates:

ggplot(...) + theme(legend.position = c(0.9, 0.9))

(0,0) corresponds to the bottom left corner and (1,1) is top right.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM