1. 使用 RMarkdown 的 child 参数,进行文档拼接。
  2. 这样拼接以后的笔记方便复习。
  3. 相关问题提交到 Issue

参考 Barrett (2019)

1 去冗余

1.1 文字不重叠

##  [1] "Ghana"       "Italy"       "Lesotho"     "Swaziland"   "Zimbabwe"   
##  [6] "Thailand"    "Gambia"      "Chile"       "Korea, Rep." "Paraguay"

2 高亮关键信息

2.3 直接命名

direct labeling 加粗,这样线上的 text 就区分大点。

参考 https://drsimonj.svbtle.com/label-line-ends-in-time-series-with-ggplot2

4 配色方案

4.1 查询 RGB

如何知道一个颜色的色号?一般如#063376定义。 一般的截图软件(如微信、QQ)都可以查询到 RGB,然后使用R的函数

## [1] "#010101"

就能知道了。

4.2 寻找马尔斯绿

目前回答了这个 知乎问题。 从抖音的一个短视频了解到这个颜色。 参考维基百科

  1. 马尔斯绿
  2. Marrs Green
  3. "#008C8C"

但是为了求证,我找了下相关原图进行验证,发现并不是,因此实践中,用这个颜色可能需要注意下。

参考维基百科中两篇介绍的报道中的图片。

  1. 感觉图像颜色有点不对,好好研究 Imperfect 的函数。

8 scales

参考 Seidel (2020a),Seidel (2020b),Seidel (2020c)

8.2 Rescale data

  • rescale rescales to a new min and max
  • rescale_mid rescales to a new mid, max, and min
  • rescale_max rescales to a new maximum
rescale 后,做数据的标准化,而且改变中位数,但是不改变分布。rescale 后,做数据的标准化,而且改变中位数,但是不改变分布。rescale 后,做数据的标准化,而且改变中位数,但是不改变分布。

Figure 8.2: rescale 后,做数据的标准化,而且改变中位数,但是不改变分布。

8.3 处理异常值

  • squish will squish your values into a specified range, respecting NAs
  • discard will drop data outside a range, respecting NAs
  • censor will return NAs for values outside a range
## [1] 0.0 0.5 1.0 1.0  NA
## [1] 0.5 1.0  NA
## [1]  NA 0.5 1.0  NA  NA

8.4 break

比cut好很多。

  • breaks_extended() sets most breaks by default in ggplot2 using Wilkonson’s algorithm
  • breaks_pretty() uses R’s default breaks algorithm
  • breaks_log() is used to set breaks for log transformed axes with log_trans().
  • breaks_width() is used to set breaks by width, especially useful for date and date/time axes.
##  [1]    0  100  200  300  400  500  600  700  800  900 1000
## [1]   70  100  200  300  400  500  700 1000
##  [1]   0   8  16  24  32  40  48  56  64  72  80  88  96 104 112

8.5 Label Formatters

  • label_number: a generic number formatter that forces intuitive decimal display of numbers
  • label_dollar, label_percent, label_comma
  • label_scientific
  • label_date, label_time : Formatted dates and times.
  • label_ordinal: add ordinal suffixes (-st, -nd, -rd, -th) to numbers according to languages (e.g. English, Spanish, French).
  • label_bytes, label_number_si
  • label_parse, label_math, label_pvalue 还有 pvalue 进行展示
  • label_wrap

附录

参考文献

Barrett, Malcolm. 2019. “Designing Ggplots: Making Clear Figures That Communicate.” GitHub. 2019. https://github.com/malcolmbarrett/designing.ggplots.

Seidel, Dana. 2020a. “The Little Package That Could: Taking Visualizations to the Next Level with the Scales Package.” RStudio Conference 2020. 2020. https://resources.rstudio.com/rstudio-conf-2020/the-little-package-that-could-taking-visualizations-to-the-next-level-with-the-scales-package-dana-seidel.

———. 2020b. “The Little Package That Could: Taking Visualizations to the Next Level with the Scales Package.” RStudio Conference 2020. 2020. https://www.danaseidel.com/rstudioconf2020.

———. 2020c. “The Little Package That Could: Taking Visualizations to the Next Level with the Scales Package.” RStudio Conference 2020. 2020. https://github.com/dpseidel/rstudioconf2020.