scale_tight | R Documentation |
Wrappers around 'ggplot2::scale_x_continuous' and 'ggplot2::scale_y_continuous' to make it easy to tighten up the axis
scale_x_tight(...)
scale_y_tight(...)
... |
Arguments to 'ggplot2::scale_x_continuous' and 'ggplot2::scale_x_continuous' |
https://github.com/thomas-neitmann/scalesextra https://stackoverflow.com/questions/44170871/how-does-ggplot-scale-continuous-expand-argument-work
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()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.