patchwork icon indicating copy to clipboard operation
patchwork copied to clipboard

Graphs getting squished

Open GabriellaS-K opened this issue 1 year ago • 1 comments

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 `

GabriellaS-K avatar Oct 01 '23 22:10 GabriellaS-K

Please use the reprex package to provide a reproducible example, as it makes it much easier to see what you are experiencing

thomasp85 avatar Oct 30 '23 08:10 thomasp85