Skip to content

Instantly share code, notes, and snippets.

@gtgrthrst
Created June 14, 2021 07:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gtgrthrst/fb16a8bc7057d09b0ae6d476ecb8b767 to your computer and use it in GitHub Desktop.
Save gtgrthrst/fb16a8bc7057d09b0ae6d476ecb8b767 to your computer and use it in GitHub Desktop.
library(ggplot2)
library(tidyr)
library(dplyr)
library(reshape)
df <- VADeaths %>%
as.data.frame() %>%
mutate(age = rownames(.)) %>%
gather(key = 'key', value = 'value', -age)
df %>% ggplot() +
geom_bar(aes(x = age, y = value, fill = key), stat = 'identity',position = "stack")+
theme(axis.title=element_blank(),
axis.text=element_blank(),
axis.ticks=element_blank())+
guides(fill = FALSE, color = FALSE, linetype = FALSE, shape = FALSE, size = FALSE) #刪除圖例
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment