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 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"))
opts
is not working with ggplot2. You need to use theme
, so instead you need to type:
+ theme(legend.key.width = unit(10, "line"))
精彩评论