2011-10-02 15 views
5

Digamos Tengo el siguiente gráfico representado mediante ggplot:¿Alguna manera de extender la línea en la leyenda?

enter image description here

¿Hay alguna forma de ampliar la cantidad de longitud de la línea se muestra en la leyenda? A veces, es imposible identificar qué línea corresponde a qué línea del gráfico usa la leyenda.

Respuesta

9

aquí es una opción 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")) 

enter image description here

+0

+1 ¡Guau! ¡¡¡Asombroso!!! Un millón de gracias :) – Legend

0

opts no está trabajando con ggplot2. Debe utilizar theme, por lo que debe escribir:

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