-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plot dbh class by species (and maybe table it?) #52
Comments
# Setup --------------------------------------------------------------------
suppressPackageStartupMessages(library(ggplot2))
plot_dbh_by_species <- function(data,
binwidth = NULL,
labels = NULL,
theme = theme_classic()) {
lapply(
split(data, data$sp),
plot_dbh,
binwidth = binwidth,
labels = labels,
theme = theme
)
}
plot_dbh <- function(data, binwidth, labels, theme) {
ggplot(data, aes(dbh)) +
geom_histogram(binwidth = binwidth) +
labels +
facet_wrap("sp", ncol = 1) +
theme
}
# Parameters to tweak ------------------------------------------------------
# Replace with your data
census <- fgeo.x::tree6_3species
# Change the width of each bar or leave it as is for automatic width
binwidth <- NULL
# Change axes labels
labels <- labs(x = "Diameter", y = "Count")
# Change theme https://ggplot2.tidyverse.org/reference/index.html#section-themes
theme <- theme_classic()
# Change size of each plot in each page
height <- 5
width <- 8
# Print each plot to a page in a .pdf file ----------------------------------
pdf("plots.pdf", paper = "letter", height = height, width = width)
plot_dbh_by_species(census, binwidth, labels, theme)
dev.off() Created on 2019-05-08 by the reprex package (v0.2.1) ResultEach page of the .pdf file should now have a plot simlar to this one: |
Suggestions by David:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
David Kenfak proposed to add a funciton to easily plot dbh classes by species.
Created on 2019-03-18 by the reprex package (v0.2.1)
--
A quick histogram may also be useful in the form of a table with the skimr package
The text was updated successfully, but these errors were encountered: