相关主题:Counts Chart ### Counts Chart 适用于两个变量做相关性分析的时候,如果重叠的点太多,除了可以使用jitter函数抖动以外,我们还可以使用geom_count函数来克服重叠点过多的情况(重叠的点越多,该位置的图形越大)
load package and data
library(ggplot2)
data(mpg, package="ggplot2")#不加参数则是数据框,加了参数就是ggplot2比较喜欢的输入格式tibble格式
# mpg <- read.csv("<http://goo.gl/uEeRGu>")
# Scatterplot
theme_set(theme_bw()) # pre-set the bw theme.
g <- ggplot(mpg, aes(cty, hwy))#第一个图层
g + geom_count(col="tomato3", show.legend=F) + # show.legend参数为是否显示图例
#颜色默认黑色也还是可以的~
labs(subtitle="mpg: city vs highway mileage",
y="hwy",
x="cty",
title="Counts Plot")
#想加右下角小标题,可以在labs函数中添加参数caption="晨曦"