labs(title="Histogram with density curve",y="Percent",x="Highway Miles Per Gallon") #核密度曲线更平滑地描述了得分的分布,使用geom_density()函数将核密度曲线绘制成红色,并设置曲线宽度;核密度曲线显示的是双峰分布(两个峰值)
geom_histogram(aes(fill = cut), binwidth = 0.1, position = "fill", na.rm = TRUE) + xlim(58, 68) + theme(legend.position = "none") #核密度图 p5 <- ggplot(diamonds, aes(depth)) + geom_density(na.rm = TRUE) + xlim(58, 68) + theme(legend.position = "none") #分组和密度...
# Histogram with density plot p18 <- ggplot(df, aes(x=weight)) + geom_histogram(aes(y=..density..), colour="black", fill="white")+ geom_density(alpha=.2, fill="#FF6666") # Color by groups p19 <- ggplot(df, aes(x=weight, color=sex, fill=sex)) + geom_histogram(aes(y=....
Overlay with transparent density plot. The value ofalphacontrols the level of transparency # Add mean line p+ geom_vline(aes(xintercept=mean(weight)), color="blue", linetype="dashed", size=1) # Histogram with density plot ggplot(df, aes(x=weight)) + geom_histogram(aes(y=..d...
+geom_histogram(binwidth=1)# Change colorsp<-ggplot(df,aes(x=weight))+geom_histogram(color="black",fill="white")p# Add mean linep+geom_vline(aes(xintercept=mean(weight)),color="blue",linetype="dashed",sieze=1)# Histogram with density plotggplot(df,aes(weight))+geom_histogram(aes(...
qplot(): Quick plot with ggplot2 Scatter plots Bar plot Box plot, violin plot and dot plot Histogram and density plots Box plots Basic box plots Box plot with dots Change box plot colors by groups Change box plot line colors Change box plot fill colors ...
The histogram is plotted with density instead of count values on y-axis Overlay with transparent density plot # Histogram with density plot ggplot(df, aes(x=weight)) + geom_histogram(aes(y=..density..), colour="black", fill="white")+ geom_density(alpha=.2, fill="#FF6666") # ...
ggplot2包中绘制点图的函数有两个:geom_point和 geom_dotplot,当使用geom_dotplot绘图时,point的形状是dot,不能改变点的形状,因此,geom_dotplot 叫做散点图(Scatter Plot),通过绘制点来呈现数据的分布,对点分箱的方法有两种:点密度(dot-density )和直方点(histodot)。当使用点密度分箱(bin)方式时,分箱的位...
使用ggMarginal() 函数 来自‘ggExtra’包 除去 histogram 也可以选则 boxplot or density图 通过设置 type 选项 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 # load package and data library(ggplot2) library(ggExtra) data(mpg, package="ggplot2") # mpg <- read.csv("http://goo.gl/uEeRG...
Density histogram Plot using the package ggplot2lfitdata