31 ggplot的各种图形 |
您所在的位置:网站首页 › 中国建筑施工企业协会会长级别 › 31 ggplot的各种图形 |
31 ggplot的各种图形
31.1 介绍
ggplot2包提供了许多种图形, 其作用可以大致地分为: 表现数量; 表现一维或者二维分布; 表现两个变量之间的数量关系,等等。下面按照其作用分别进行介绍。 主要参考: Claus O. Wilke(2019). Fundamentals of Data Visualization. O’Reilly Media. https://serialmentor.com/dataviz/ 31.2 表现数量 31.2.1 条形图设有若干个类, 每个类有一个数量属性值。 经常用条形图表现数量。 31.2.1.1 简单的条形图例如, 有25个共同基金, 分为三个类别, 各类别的频数为: d_funds_type d_gap用点图表现各大洲的最大期望寿命: p % select(continent, year, lifeExp) %>% group_by(continent, year) %>% summarise(lifeExp = median(lifeExp, na.rm=TRUE)) %>% ungroup() -> d_gap2a ## `summarise()` has grouped output by 'continent'. You can override using the ## `.groups` argument. d_gap2a %>% filter(year == 2007) %>% arrange(desc(lifeExp)) -> d_gap2b d_gap2a %>% mutate(continent = factor(continent, levels = d_gap2b$continent)) -> d_gap2上面的程序中将各大洲的次序调整为最后一年的中位期望寿命。 作热力图: p d p |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |