knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The goal of plotutils is to provide utility functions for plotting in R, primarily focused on \code{ggplot2} plots.
You can install plotutils
from GitHub with:
# install.packages("devtools") devtools::install_github("MiguelRodo/plotutils")
library(plotutils)
Fix axis limits to be equal between x- and y-axes, and/or expand axis coordinates.
data('cars', package = 'datasets') library(ggplot2) p0 <- ggplot(cars, aes(speed, dist)) + cowplot::theme_cowplot(font_size = 12) + cowplot::background_grid(major = 'xy') + geom_point() + theme(plot.title = element_text(hjust = 0.5)) + labs(title = "Axes unadjusted") + labs(x = "Speed", y = "Distance") p1 <- axis_limits( p = p0, limits_equal = TRUE ) + labs(title = "Axes limits equal") p2 <- axis_limits( p = p0, limits_expand = list( x = c(0, 50), y = c(-10, 200) ) ) + labs(title = "Axes limits expanded") cowplot::plot_grid(p0, p1, p2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.