{
"hash": "1f512aedde0c78d18d7113364c7ce0db",
"result": {
"engine": "knitr",
"markdown": "---\ntitle: \"数据可视化\"\nsubtitle: 《区域水环境污染数据分析实践》
Data analysis practice of regional water environment pollution\nauthor: 苏命、王为东
中国科学院大学资源与环境学院
中国科学院生态环境研究中心\ndate: today\nlang: zh\nformat:\n revealjs:\n theme: dark\n slide-number: true\n chalkboard:\n buttons: true\n preview-links: auto\n lang: zh\n toc: true\n toc-depth: 1\n toc-title: 大纲\n logo: ./_extensions/inst/img/ucaslogo.png\n css: ./_extensions/inst/css/revealjs.css\n pointer:\n key: \"p\"\n color: \"#32cd32\"\n pointerSize: 18\nrevealjs-plugins:\n - pointer\nfilters:\n - d2\nknitr:\n opts_chunk:\n dev: \"svg\"\n retina: 3\nexecute:\n freeze: auto\n cache: true\n echo: true\n fig-width: 5\n fig-height: 6\n---\n\n\n\n\n\n\n## {background-image=\"../../img/concepts/tidyverse-packages-ggplot.png\" background-position=\"center\" background-size=\"100%\"}\n\n\n\n## The ggplot2 Package\n\n
\n\n... is an **R package to visualize data** created by Hadley Wickham in 2005\n\n\n::: {.cell}\n\n```{.r .cell-code}\n# install.packages(\"ggplot2\")\nlibrary(ggplot2)\n```\n:::\n\n\n
\n\n::: fragment\n... is part of the [`{tidyverse}`](https://www.tidyverse.org/)\n\n\n::: {.cell}\n\n```{.r .cell-code}\n# install.packages(\"tidyverse\")\nlibrary(tidyverse)\n```\n:::\n\n:::\n\n# The Grammar of {ggplot2}\n\n\n\n## The Grammar of {ggplot2}\n\n
\n
Component | \nFunction | \nExplanation | \n
---|---|---|
Data | \nggplot(data) | \n *The raw data that you want to visualise.* | \n
Aesthetics | \naes() | \n *Aesthetic mappings between variables and visual properties.* | \n
Geometries | \ngeom_*() | \n *The geometric shapes representing the data.* | \n
Component | \nFunction | \nExplanation | \n
---|---|---|
Data | \nggplot(data) | \n *The raw data that you want to visualise.* | \n
Aesthetics | \naes() | \n *Aesthetic mappings between variables and visual properties.* | \n
Geometries | \ngeom_*() | \n *The geometric shapes representing the data.* | \n
Statistics | \nstat_*() | \n *The statistical transformations applied to the data.* | \n
Scales | \nscale_*() | \n *Maps between the data and the aesthetic dimensions.* | \n
Coordinate System | \ncoord_*() | \n *Maps data into the plane of the data rectangle.* | \n
Facets | \nfacet_*() | \n *The arrangement of the data into a grid of plots.* | \n
Visual Themes | \ntheme() / theme_*() | \n *The overall visual defaults of a plot.* | \n
Variable | \nDescription | \nClass | \n
---|---|---|
date | \nDate encoded as `YYYY-MM-DD` | \ndate | \n
day_night | \n`day` (6:00am–5:59pm) or `night` (6:00pm–5:59am) | \ncharacter | \n
year | \n`2015` or `2016` | \nfactor | \n
month | \n`1` (January) to `12` (December) | \nfactor | \n
season | \n`winter`, `spring`, `summer`, or `autumn` | \nfactor | \n
count | \nSum of reported bikes rented | \ninteger | \n
is_workday | \n`TRUE` being Monday to Friday and no bank holiday | \nlogical | \n
is_weekend | \n`TRUE` being Saturday or Sunday | \nlogical | \n
is_holiday | \n`TRUE` being a bank holiday in the UK | \nlogical | \n
temp | \nAverage air temperature (°C) | \ndouble | \n
temp_feel | \nAverage feels like temperature (°C) | \ndouble | \n
humidity | \nAverage air humidity (%) | \ndouble | \n
wind_speed | \nAverage wind speed (km/h) | \ndouble | \n
weather_type | \nMost common weather type | \ncharacter | \n