-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Graphs getting squished #335
Labels
reprex
needs a minimal reproducible example
Comments
Please use the reprex package to provide a reproducible example, as it makes it much easier to see what you are experiencing |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello!
Thanks for a wonderful package!
My issue is with the squishing of wordy graphs.
These are some word frequency graphs taken from Julie Silge comprehensive tutorial: https://juliasilge.com/blog/term-frequency-tf-idf/
The issue is similar to #319 but the fix didn't work
These four graphs get really squished, or if I put it one above the other, stacked vertically it also looks very weird! I would appreciate some suggestions on how to fix this, I've been grappling with it for ages :(
`
library(dplyr)
library(janeaustenr)
library(tidytext)
book_words <- austen_books() %>%
unnest_tokens(word, text) %>%
count(book, word, sort = TRUE) %>%
ungroup()
total_words <- book_words %>% group_by(book) %>% summarize(total = sum(n))
book_words <- left_join(book_words, total_words)
book_words <- book_words %>%
bind_tf_idf(word, book, n)
library(ggstance)
library(ggthemes)
plot_austen <- book_words %>%
arrange(desc(tf_idf)) %>%
mutate(word = factor(word, levels = rev(unique(word))))
plot_austen_gg<-ggplot(plot_austen[1:20,], aes(tf_idf, word, fill = book, alpha = tf_idf)) +
geom_barh(stat = "identity") +
labs(title = "Highest tf-idf words in Jane Austen's Novels",
y = NULL, x = "tf-idf") +
theme_tufte(base_family = "Arial", base_size = 13, ticks = FALSE) +
scale_alpha_continuous(range = c(0.6, 1), guide = FALSE) +
scale_x_continuous(expand=c(0,0)) +
theme(legend.title=element_blank()) +
theme(legend.justification=c(1,0), legend.position=c(1,0))
library(patchwork)
plot_austen_gg+plot_austen_gg+plot_austen_gg+plot_austen_gg
#or
plot_austen_gg/plot_austen_gg/plot_austen_gg/plot_austen_gg
`
The text was updated successfully, but these errors were encountered: