-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME.Rmd
161 lines (121 loc) · 4.96 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
library(ggpsychro)
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
fig.align = "center",
out.width = "60%",
dev = "png",
dpi = 100
)
```
# ggpsychro
<!-- badges: start -->
[![AppVeyor build status](https://ci.appveyor.com/api/projects/status/github/hongyuanjia/ggpsychro?branch=master&svg=true)](https://ci.appveyor.com/project/hongyuanjia/ggpsychro)
[![Travis build status](https://travis-ci.com/hongyuanjia/ggpsychro.svg?branch=master)](https://travis-ci.com/hongyuanjia/ggpsychro)
[![Codecov test coverage](https://codecov.io/gh/hongyuanjia/ggpsychro/branch/master/graph/badge.svg)](https://codecov.io/gh/hongyuanjia/ggpsychro?branch=master)
[![CRAN status](https://www.r-pkg.org/badges/version/ggpsychro)](https://CRAN.R-project.org/package=ggpsychro)
<!-- badges: end -->
> 'ggplot2' extension for making psychrometric charts.
## Installation
<!-- You can install the released version of ggpsychro from [CRAN](https://CRAN.R-project.org) with: -->
<!-- ``` r -->
<!-- install.packages("ggpsychro") -->
<!-- ``` -->
You can install the development version from [GitHub](https://github.com/) with:
``` r
# install.packages("remotes")
remotes::install_github("hongyuanjia/ggpsychro")
```
## Example
### The basic
Similar with ggplot2, the creation of a psychrometric chart using ggpsychro starts with function
`ggpsychro()`. You can specify the range of dry-bulb temperature and humidity
ratio using `tab_lim` and `hum_lim` and the unit system using `units`
```{r ggpsychro}
ggpsychro(tdb_lim = c(0, 50), hum_lim = c(0, 50), units = "IP")
```
You can also create a mollier chart by setting `mollier` to `TRUE`.
```{r mollier}
ggpsychro(mollier = TRUE)
```
By default, only dry-bulb temperature, humidity ratio and the saturation line
are plotted.
The style of the saturation and area above it can be further styled using
`sat_style` and `mask_style`.
```{r style}
ggpsychro(mask_style = list(fill = "gray"), sat_style = list(color = "black", linetype = 2))
```
### Grid
ggpsychro introduces new ggplot geoms to add 5 more grids onto the base plot:
| Geom | Type |
| --- | --- |
| `geom_grid_relhum` | Relative humidity |
| `geom_grid_wetbulb` | Wet-bulb temperature |
| `geom_grid_vappres` | Vaper pressure |
| `geom_grid_specvol` | Specific volume |
| `geom_grid_enthalpy` | Enthalpy |
```{r grid, out.width = "100%", dpi = 300, fig.width = 15, fig.height = 10}
ggpsychro() +
geom_grid_relhum() +
geom_grid_wetbulb() +
geom_grid_vappres() +
geom_grid_specvol() +
geom_grid_enthalpy()
```
Each of the new geom come along with a corresponding `scale_*` which can be used
to further customize the breaks of each grid
```{r grid-2, out.width = "100%", dpi = 300, fig.width = 15, fig.height = 10}
ggpsychro() +
geom_grid_relhum(alpha = 1.0, label.alpha = 1.0, label.size = 6, label.fontface = 2) +
scale_relhum(minor_breaks = NULL) +
geom_grid_wetbulb(size = 1.0, color = "black", alpha = 1.0, label_loc = NA) +
scale_wetbulb(breaks = seq(25, 30, by = 5), minor_breaks = NULL) +
geom_grid_vappres(label.size = 5) +
scale_vappres(breaks = seq(6000, 7000, by = 500), limits = c(6000, 7000)) +
geom_grid_specvol() +
scale_specvol(labels = NULL) +
geom_grid_enthalpy()
```
### Stat
ggpsychro provides 5 new ggplot stats to use together with other common ggplot2
geoms::
| Stat | Type |
| --- | --- |
| `stat_relhum` | Relative humidity |
| `stat_wetbulb` | Wet-bulb temperature |
| `stat_vappres` | Vaper pressure |
| `stat_specvol` | Specific volume |
| `stat_enthalpy` | Enthalpy |
This makes it quick easy to add new elements.
Working together with ggplot2 orignal geoms is as simple as change `stat` to
your variable name of interest.
```{r stat-1}
library(eplusr) # for reading EPW data
epw <- read_epw(file.path(eplus_config(8.8)$dir, "WeatherData/USA_CO_Golden-NREL.724666_TMY3.epw"))
ggpsychro(epw$data()[month %in% 5:8]) +
geom_grid_relhum() +
geom_point(aes(dry_bulb_temperature, relhum = relative_humidity/100), stat = "relhum", alpha = 0.1) +
facet_wrap(~month, labeller = as_labeller(function (x) paste0("Month: ", x)))
```
```{r stat-2}
ggpsychro(tdb_lim = c(10, 35), hum_lim = c(0, 30)) +
geom_grid_relhum() +
geom_grid_wetbulb() +
# 18 wet-bulb line with dry-bulb from 20 - 30
geom_line(aes(x = 20:30, wetbulb = 18), stat = "wetbulb")
```
## Author
Hongyuan Jia
## License
The project is released under the terms of MIT License.
Copyright © 2019-2020 Hongyuan Jia
## Contribute
Please note that the 'ggpsychro' project is released with a
[Contributor Code of Conduct](.github/CODE_OF_CONDUCT.md).
By contributing to this project, you agree to abide by its terms.