Skip to content

Instantly share code, notes, and snippets.

@luisDVA
Created November 17, 2020 17:58
Show Gist options
  • Save luisDVA/d80f9699ef5857d506a2872c2bf7609a to your computer and use it in GitHub Desktop.
Save luisDVA/d80f9699ef5857d506a2872c2bf7609a to your computer and use it in GitHub Desktop.
library(ggplot2)
library(dplyr)
# datos internos que vienen con ggplot2
animals <-
msleep %>% slice_max(sleep_rem, n = 30) %>% # seleccionando top 30
ggplot(aes(x = forcats::fct_reorder(name, sleep_total), y = sleep_total, label = name)) +
geom_bar(stat = "identity") + xlab("") +
geom_text(nudge_y = 2, hjust = 0) +
theme(
axis.text.y = element_blank(),
axis.ticks.y = element_blank()
) +
coord_flip() +
scale_y_continuous(expand = c(0, 1), limits = c(0, 25)) # espacio extra en el eje
animals
animals_pltly <- plotly::ggplotly(animals)
plotly::plotly_json(animals_pltly)
@mevangelista-alvarado
Copy link

Gracias!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment