简体   繁体   中英

r change the orientation of the symbol in the legend

I have this little R script

library(ggplot2)
library(data.table)

dt = data.table(x = c(1, 2), ymin = c(1,0), ymax = c(2, 1.3), size = c(1, 2))

p <- ggplot()
p <- p + geom_linerange(data = dt, aes(x = x, ymin = ymin, ymax = ymax, size = as.factor(size)))
p <- p + scale_size_discrete(range = c(1, 2), guide = guide_legend(title="I   want to rotate the lines (symbols) by 90 degree"))

p

The width of the line has some important meaning and I want to reflect this in the legend, but I want to have vertical lines instead of horizontal lines.

Do you have any idea, the little picture shows what I want, I just changed the color of the symbol for demonstration purposes :-)

在此处输入图片说明

Using the current dev version of ggplot2 from github resolves my problem :-) 在此处输入图片说明

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