knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "README_files/README-" )
This package facilitates the use of the official ERCOT palette with ggplot2 plots.
You can install this package from GitHub by calling devtools::install_github("aelhabr/ercotr").
Note the global variables that are loaded into your environment when loading this package. These include:
ercot_paletteercot_palette2ercot_palette_w_contrast (alias to ercot_palette)ercot_palette_wo_contrast (alias to ercot_palette2)These variables are used in the scale_color/fill_ercot()
and scale_color/fill_ercot2() functions respectively.
The 2 variation implement the ordering of the actual official ERCOT palette
(i.e. turquoise first, grey second, light green third, etc.)
while the un-suffixed counterparts reflect a subjective re-ordering
of the same colors that (arguably) improve the contrast in plots.
(For example, maroon is the second color instead of grey in the non-suffixed
palette because it (arbuably) contrasts better with the
first color, turquoise.) Please feel free to use either of these built-in palettes,
or to re-order the colors to your liking (e.g. by calling ercot_palette[c(1, 8, 6)], etc.).
In general, it is recommended to only use the scale_color/fill_ercot() and
scale_color/fill_ercot2() functions directly.
(Correspodningly, it is not recommended to use other available functions,
such asercot_pal() and ercot_pal2(), directly.
Note that these functions exist primarily to serve as analogues to t
he ggplot2 manual_pal() function.)
These examples are very similar shown in the README file for the teutils package.
library("ggplot2") library("ercotr") scales::show_col(ercotr::ercot_pal()(11)) viz_labs <- labs(title = "A Title.", subtitle = "A subtitle.", caption = "A caption.") viz_cars <- ggplot(mtcars, aes(x = wt, y = mpg, color = factor(gear))) + geom_point(size = 2) + geom_smooth(method = "lm", se = FALSE, size = 2) + viz_labs viz_cars_facet <- viz_cars + facet_wrap(~ am) viz_diamonds <- ggplot(diamonds, aes(x = clarity, fill = cut)) + geom_bar() + viz_labs viz_cars + theme_grey() viz_cars + scale_color_ercot() + theme_minimal() viz_cars_facet + theme_grey() viz_cars_facet + scale_color_ercot() + theme_minimal() viz_diamonds + scale_fill_ercot() + theme_minimal() viz_diamonds + scale_fill_ercot2() + theme_minimal()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.