ggplot2 ggplot()
p<-ggplot(diamonds,aes(carat, price))
p + geom_point(colour="red")
p + geom_point(aes(colour= color, shape= color))
p + geom_histogram(stat="identity", binwidth = 500)
p + geom_path()
p + geom_line()
p + geom_point(aes(colour= color, size= cut), alpha= 0.8, position = "jitter")+
stat_smooth()+
facet_wrap(~color, ncol = 1)+
ggtitle("钻石的价格")+
labs(y='price', x="carat")+
guides(size= guide_legend('cut'),
colour= guide_legend(title = '颜色'))
#位置调整(Position adjustments)是针对同一图层内元素的位置进行微调的方法。
#它包括五种设置,分别是stack、dodge、fill、identity、jitter
ggtitle(label, subtitle = NULL)
ggplot(mpg, aes(class, cyl)) +
geom_count() + #记录重叠点数
scale_size_area()
# If you want zero value to have zero size, use scale_size_area:
p + scale_size_area()


浙公网安备 33010602011771号