坐标轴 axis
- 修改名称:xlab("name") ylab("name")
- 删除坐标轴刻度:theme(axis.text.x = element_blank())
分面
facet_wrap(~ variable, scales = "XX")
scales = "fixed"/"free",前者所有图坐标轴刻度相同,后者反之
scatterplot
点的形状:shape
boxplot
barplot
categorical variable分类变量如何画频率分布条形图
dat <- data %>%
group_by(Year,duration)%>%
summarize(count = n())%>%
mutate(perc = count / sum(count)) #求percentage
#画出yearly frequency distribution of duration(categorical variable)
ggplot(dat, aes(x=duration, y = perc, fill = duration)) +
geom_bar(stat = "identity")+
facet_wrap(~ Year, scales = "fixed")+
theme(axis.text.x = element_blank())+
ylab("Percent")