How to increase size or dynamically change the size of wordcloud2.

I have created this app: Coronamusic Database (

The wordcloud looks decent on my small monitor:

However when moved to my large monitor, I wish that the image would increase in size:

Additionally, even on my small monitor, when there are fewer words, it does not look that great:

And it looks horrible on the large monitor:

My impression is that this is an active issue with the library wordcloud2. Initially there were words being omitted from the wordclouds if they had appeared too many times in the dataset to fit on the canvas ( Omitted words warning? · Issue #56 · Lchiffon/wordcloud2 ( I solved the issue by finding the largest font size that would allow all the words to show for every possible wordcloud (the biggest word being "togetherness" in the emotions wordcloud.

colorpalette<-c("darkviolet", "cyan", "violet","gold", "mediumspringgreen") 
colorVec<-rep(colorpalette, length.out=nrow(wordlist))
wordcloud2(wordlist,rotateRatio = 0.3, color = colorVec, backgroundColor = "black", size = 0.4, widgetsize =c("1000","1000")) 

I was hoping the widget size argument would help but it does not seem to be doing anything. It seems like the size of the words is being controlled exclusively by the word size and even trying to adjust the size of the widget in the UI is not having an effect. I think a reasonable work-around would be to resize the font size dynamically based on the selected variable however I have been unable to figure out a reasonable logic for this given that the wordcloud building process does not seem to provide information accessible to R since it doesn't even flag when a word hasn't been printed.

I also briefly investigated how resizing the widget might help ( Widget sizing ( however I couldn't figure this out because it seems like the wordcloud2 uses a sizing policy that would make it work with multiple screen dimensions.
Excerpt from wordcloud 2 code ( wordcloud2/wordcloud2.R at master · Lchiffon/wordcloud2 (

sizingPolicy = htmlwidgets::sizingPolicy(
                              viewer.padding = 0,
                              # viewer.suppress = T,
                              browser.padding = 0,
                              browser.fill = TRUE

Here is a minimally reproducible example in case this helps.

# min rep example of wordcloud
words<-c("one", "two", "three", "four")
wordlist<-data_frame(words, count)

    sidebarPanel = sidebarPanel(
      checkboxInput("checkbox", "Plot wordcloud!")
  mainPanel = mainPanel(
    wordcloud2Output('wordcloud', width = "auto") # I have also tried: width = "100%"
  position = c("left", "right"),
  fluid = TRUE

server<-function(input, output, session){
    colorpalette<-c("darkviolet", "cyan", "violet","gold", "mediumspringgreen") # , darkturquoise", "aquamarine" turquoise
    colorVec<-rep(colorpalette, length.out=nrow(wordlist))
    if (input$checkbox ==TRUE){
      wordcloud2(wordlist,rotateRatio = 0.3, color = colorVec, backgroundColor = "black", size = 0.4, widgetsize =c("1000","1000")) #, widgetsize = "200%"

# Create Shiny app ----
shinyApp(ui, server, options = list(height = 1000))

You can also find the full code for the app here: dana-and-monsters/corona-music-database: Shiny web application for visualizing data collected in the corona music database. (

Thank you so much for any and all help! Unrelated feedback on the app and its code is also very appreciated!

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.