library("plyr") library("dplyr") library("rgdal") library("sf") library(maptools) library("ggplot2") library("ggthemes") library("geojsonio") options(stringsAsFactors=FALSE,warn=FALSE,encoding="UTF-8") 今
stat_boxplot:绘制箱线图,显示一个连续变量的五个重要统计量,包括最小值、第一四分位数、中位数、第三四分位数和最大值,以及异常值。 stat_ydensity:绘制沿 y 轴的密度图,即将数据在 y 轴上按顺序排列,并为每个 y 值绘制一条密度曲线。 stat_ecdf:绘制经验累积分布函数图,表示一个变量的累积分布函数。
#描述的直方图的图层所默认的stat_bin的统计变换,并使用了三个新的统计变量中的默认的 #计数个数的变量count,因此纵坐标是count(各组的计数) #当然还可以对直方图使用第二个统计变量:density(概率密度) ggplot(diamonds, aes(price)) + geom_histogram(aes(y = ..density..), binwidth = 500) #注意这里den...
ggplot(mpg, aes(displ, hwy, color = class)) + geom_point() + stat_smooth(se = FALSE, method = lm) 注:以下为ggplot2提供的其他统计变换方式,也可以自己写函数基于原始数据进行计算。 stat_abline stat_contour stat_identity stat_summary stat_bin stat_density stat_qq stat_summary2d stat_bin2d ...
stat_bindot stat_ecdf stat_smooth stat_unique stat_binhex stat_function stat_spoke stat_vline stat_boxplot stat_hline stat_sum stat_ydensity 1. 2. 3. 4. 5. 6. 六 坐标系统(Coordinante) 坐标系统控制坐标轴,可以进行变换,例如XY轴翻转,笛卡尔坐标和极坐标转换,以满足我们的各种需求。
因为在ggplot2中一直没有看到好的关于密度辐射图(或者称它为热力辐射图,就是那种PowerMap中可以通过颜色色度探查区域指标分布密度的图表类型)的合适解决方案,最近在看github官网上ggmap的介绍帖,看到作者在ggmap函数中嵌套了geom_polygon图层并并使用fill=..level..参数和stat="density_2d"来来制作类似的热度辐射图。
, stat = "bin") 1. 可以通过修改不同属性如透明度、填充颜色、大小、线型等自定义图形: 密度图 使用以下函数: geom_density():绘制密度图 geom_vline():添加竖直线 scale_color_manual():手动修改颜色 a+geom_density() 1. 根据sex修改颜色,将sex映射给line颜色 a+geom_density(aes(color=sex)) 1. ...
aes(size = ..density..), binwidth = 0.1, geom ="point", position="identity" ) stat_bin is suitable onlyforcontinuous x data. If your x data is discrete, you probably want to use stat_count. p <-ggplot(diamonds,aes(carat)) +xlim(0, 3) ...
ggplot(mpg, aes(displ, hwy, color = class)) + geom_point() + stat_smooth(se = FALSE, method = lm) 注:以下为ggplot2提供的其他统计变换方式,也可以自己写函数基于原始数据进行计算。 stat_abline stat_contour stat_identity stat_summarystat_bin stat_density stat_qq stat_summary2dstat_bin2d sta...
Functions:geom_point(),geom_smooth(),stat_smooth(),geom_rug(),geom_density_2d(),stat_density_2d(),stat_bin_2d(),geom_bin2d(),stat_summary_2d(),geom_hex() (seestat_bin_hex()),stat_summary_hex() Bar plots Basic bar plots