开发者

Any way to extend the line in the legend?

开发者 https://www.devze.com 2023-04-10 15:56 出处:网络
Let us say I have the following graph plotted using ggplot: Is there anyway to extend how much line length is开发者_开发百科 displayed in the legend? Sometimes, it just gets impossible to identify

Let us say I have the following graph plotted using ggplot:

Any way to extend the line in the legend?

Is there anyway to extend how much line length is开发者_开发百科 displayed in the legend? Sometimes, it just gets impossible to identify which line correspond to which line in the graph using the legend.


here is an option legend.key.width:

# sample data frame
df <- data.frame(x = c(rnorm(100, -3), rnorm(100), rnorm(100, 3)), 
                 g = gl(3, 100))
df <- ddply(df, .(g), summarize, x = x, y = ecdf(x)(x))

ggplot(df, aes(x, y, colour = g, linetype = g)) + 
    geom_line() + 
    theme(legend.key.width = unit(10, "line"))

Any way to extend the line in the legend?


opts is not working with ggplot2. You need to use theme, so instead you need to type:

+ theme(legend.key.width = unit(10, "line"))
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号