# hadley's settings set.seed(1014) options(digits = 3) knitr::opts_chunk$set( echo = TRUE, # {mine} comment = "#>", collapse = TRUE, # cache = TRUE, out.width = "100%", fig.align = "center", fig.width = 6, fig.asp = 0.618, # 1 / phi fig.show = "hold", rows.print = 3 # {mine} )
This article compares plots built with fgeo.plot versus ggplot2.
Data
# https://forestgeo.github.io/fgeo.plot/ library(fgeo.plot) elevation <- fgeo.data::luquillo_elevation str(elevation) # Pull elevation dataframe elev <- elevation$col
Auto-plots with fgeo.plot.
plot_elevation(elev)
# plot_elevation() also understands the elevation list, so this code outputs the same plot_elevation(elevation)
# You have a number of options you can tweak plot_elevation(elev, # Or choose colors by code from http://bit.ly/2rJgQba low = "grey", high = "black", # How many lines, and how thick bins = 20, contour_size = 0.5, # Hide elevation numbers from inside the plot add_elevation_labels = FALSE, # Keep the "level" legend hide_color_legend = FALSE )
More flexible maps with ggplot2.
# http://ggplot2.tidyverse.org/reference/ library(ggplot2) ggplot(elev, aes(x = x, y = y, z = elev)) + geom_raster(aes(fill = elev)) + geom_contour(color = "white", bins = 20) + scale_fill_gradient(low = "grey", high = "black") + coord_equal() + theme_bw()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.