Created
November 17, 2020 17:58
-
-
Save luisDVA/d80f9699ef5857d506a2872c2bf7609a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Gracias!