library(gcookbook) # For the data set
sp <- ggplot(diamonds, aes(x=carat, y=price))
sp + geom_point()
sp + geom_point(alpha=.1)
library(gcookbook) # For the data set
sp <- ggplot(diamonds, aes(x=carat, y=price))
sp + stat_bin2d()
sp + stat_bin2d(bins=50) +
scale_fill_gradient(low="lightblue", high="red", limits=c(0, 6000))
sp <- ggplot(diamonds, aes(x=carat, y=price))
sp + stat_bin2d()
sp + stat_bin2d(bins=50) +
scale_fill_gradient(low="lightgreen", high="red", limits=c(0, 6000))
library(gcookbook) # For the data set
sp <- ggplot(diamonds, aes(x=carat, y=price))
sp + stat_binhex()
sp + stat_binhex(bins=50) +
scale_fill_gradient(low="lightgreen", high="red", limits=c(0, 6000))
sp + stat_binhex(bins=50) +
scale_fill_gradient(low="lightcoral", high="purple", limits=c(0, 6000))
sp1 <- ggplot(ChickWeight, aes(x=Time, y=weight))
sp1 + geom_point(color='purple')+scale_fill_manual(values=c("red", "blue", "green"))
library(gcookbook) # For the data set
sp1 <- ggplot(ChickWeight, aes(x=Time, y=weight))
sp1 + geom_point(color='violet')
library(gcookbook) # For the data set
sp1 <- ggplot(ChickWeight, aes(x=Time, y=weight))
sp1 + geom_point(position="jitter",color='purple')
library(gcookbook) # For the data set
sp1 <- ggplot(ChickWeight, aes(x=Time, y=weight))
sp1 + geom_point(position="jitter",color='violet')
library(gcookbook) # For the data set
sp1 <- ggplot(ChickWeight, aes(x=Time, y=weight))
sp1 + geom_point(position=position_jitter(width=.5, height=0),color='violet')+ geom_count(color='violet')
library(gcookbook) # For the data set
sp1 <- ggplot(ChickWeight, aes(x=Time, y=weight))
sp1 + geom_point(position=position_jitter(width=.5, height=0),color='purple')+ geom_count(color='purple')
参考文献:Practical Receipes for Visualizing Data----R Graphics Cookbook —Winston Chang O’REILLY
开发环境:RStudio和微信截屏工具