Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR R

ggplot - subset top 10 in a stack bar plot

stack <- ggplot(data_melt, 
         aes(x = reorder(name, value, FUN = sum), y = value, 
             fill= variable)) + 
             geom_bar(stat = "identity", width = 0.8) + 

             # zoom in to last 10 bars on the axis
             scale_x_discrete(expand = c(0, 0.5)) +
             coord_flip(xlim = c(length(unique(data_melt$name))-9,
                                 length(unique(data_melt$name)))) 
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #ggplot #subset #top #stack #bar #plot
ADD COMMENT
Topic
Name
4+8 =