New styling functions, new arguments to plot_*()
, and bug fixes.
r2dii-plot 0.2.0 is now on CRAN. This is a minor release with new features, enhancements and bug fixes. This post focuses on the new features. For everything else see the changelog.
You can install r2dii.plot from CRAN with:
install.packages("r2dii.plot")
And you can use it with library()
. Here we’ll also use the ggplot2 package.
library(ggplot2, warn.conflicts = FALSE)
library(r2dii.plot)
A new family of functions help you apply 2DII colour palettes to any plot.
Note this plot uses data and functions from the ggplot2 package exclusively.
p <- ggplot(mpg) + geom_point(aes(displ, hwy, color = class))
p
You can now use r2dii.plot to apply 2DII’s colour scale with:
p + scale_colour_r2dii()
To discover other functions in the “2dii scale” family run ?scale_colour_r2dii()
and navigate to the section “See also”.
plot_*()
The plot_*()
functions gained new arguments to replicate features of the qplot_*()
functions.
For example, compare these two plots. Note the shorter (5 years) time span and nicer legend labels in the plot created with qplot_*()
.
data <- subset(sda, sector == "cement")
qplot_emission_intensity(data)
plot_emission_intensity(data)
You can now replicate those features of qplot_*()
with the new arguments span_5yr
and convert_label
:
plot_emission_intensity(data, span_5yr = TRUE, convert_label = to_title)
Thanks to @cjyetman for proposing the scale_*()
functions, to @georgeharris2deg for reporting bugs, and to all contributors to this release (AlexAxthelm, maurolepore, MonikaFu).
For attribution, please cite this work as
Lepore (2021, Oct. 18). Data science at 2DII: r2dii.plot 0.2.0 is now on CRAN. Retrieved from https://2degreesinvesting.github.io/posts/2021-10-18-r2dii-plot-0-2-0/
BibTeX citation
@misc{lepore2021r2dii.plot, author = {Lepore, Mauro}, title = {Data science at 2DII: r2dii.plot 0.2.0 is now on CRAN}, url = {https://2degreesinvesting.github.io/posts/2021-10-18-r2dii-plot-0-2-0/}, year = {2021} }