30 ggplot的各种图形 您所在的位置:网站首页 ggplot2画分布图 30 ggplot的各种图形

30 ggplot的各种图形

2022-06-13 04:33| 来源: 网络整理| 查看: 265

30 ggplot的各种图形 30.1 介绍

ggplot2包提供了许多种图形, 其作用可以大致地分为:

表现数量; 表现一维或者二维分布; 表现两个变量之间的数量关系,等等。

下面按照其作用分别进行介绍。

主要参考:

Claus O. Wilke(2019). Fundamentals of Data Visualization. O’Reilly Media. https://serialmentor.com/dataviz/ 30.2 表现数量 30.2.1 条形图

设有若干个类, 每个类有一个数量属性值。 经常用条形图表现数量。

30.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 实验室设备网 版权所有