Answers for "ggplot - subset top 10 in a stack bar plot"

R
0

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))))
Posted by: Guest on August-05-2020

Browse Popular Code Answers by Language