scale_tight: Axis formatting tight to the plot

scale_tightR Documentation

Axis formatting tight to the plot

Description

Wrappers around 'ggplot2::scale_x_continuous' and 'ggplot2::scale_y_continuous' to make it easy to tighten up the axis

Usage

scale_x_tight(...)

scale_y_tight(...)

Arguments

...

Arguments to 'ggplot2::scale_x_continuous' and 'ggplot2::scale_x_continuous'

References

https://github.com/thomas-neitmann/scalesextra https://stackoverflow.com/questions/44170871/how-does-ggplot-scale-continuous-expand-argument-work

Examples

library(dplyr)
library(ggplot2)
library(palmerpenguins)

penguins %>%
  ggplot(data = .,
         aes(x = flipper_length_mm,
             y = body_mass_g,
             colour = species,
             shape = species)) +
  geom_point()

penguins %>%
  ggplot(data = .,
         aes(x = flipper_length_mm,
             y = body_mass_g,
             colour = species,
             shape = species)) +
  geom_point() +
  scale_x_tight()


penguins %>%
  dplyr::count(species) %>%
  mutate(pct = n / sum(n)) %>%
  ggplot(data = .,
         aes(x = species,
             y = pct)) +
  geom_bar(stat = "identity")

penguins %>%
  dplyr::count(species) %>%
  mutate(pct = n / sum(n)) %>%
  ggplot(data = .,
         aes(x = species,
             y = pct)) +
  geom_bar(stat = "identity") +
  scale_y_tight()


emilelatour/laviz documentation built on Oct. 15, 2023, 1:41 p.m.