Choosing Between Plotly and Leaflet for Choroplethic Maps in Shiny Apps

Hello everyone,

I hope this is the right place to ask this question. I’m currently working on building Shiny apps with interactive choroplethic maps and I’d like to gather some insights on the advantages and disadvantages of using Plotly versus Leaflet for this purpose.


I’ve noticed that there are two popular options for rendering choroplethic maps in Shiny apps: Plotly and Leaflet. I’d like to explore the strengths and weaknesses of each to make an informed choice for my project. Here are some of my initial observations:


  • Pros:

    • It seems to be faster, especially when coding directly in Plotly, as opposed to using ggplot and then converting with ggplotly.
    • It offers a cleaner look, especially as it doesn’t require map tiles.
  • Cons:

    • I’ve encountered challenges in creating visually appealing popup labels.
    • Struggling to use images/icons effectively for plotting points.


  • Pros:
    • Potentially more flexibility in customizing and popups.
  • Cons:
    • May be slower compared to Plotly.
    • Is it indeed necessary to use tiles, I’m trying to avoid the gray background while using mapBox :frowning:

Discussion Questions:

  1. Preference: Which library do you prefer for creating choroplethic maps in Shiny, Plotly, or Leaflet? Why?
  2. Performance: Have you noticed significant differences in performance between the two libraries in terms of map rendering and responsiveness?

Please feel free to share your experiences and any best practices you’ve discovered when using these libraries in your Shiny apps. If you know of any other libraries besides Plotly and Leaflet that stand out in creating choroplethic maps for Shiny apps, please do share your insights. Your input will greatly help me and others.

Thank you in advance for your contributions!

Hi Lucca, thanks for asking here!

Tagging @amy.mikhail @ChrisJ @mcewenkhundi @oboyd @andysouth @yurieizawa for thoughts.

I am assuming that you want the maps to be interactive? If so I’d also raise tmap and mapview as options to consider.

Thanks for the contribution Neale, and yes, I need interactivity on the maps.

Hi Lucca,

I would suggest creating a boundary box for the country / region of interest, downloading the map tiles and then forcing leaflet to use the saved ones instead of loading them fresh each time. I haven’t tested this, but it might be quicker. I have an app using leaflet where I will be adding an option to download the map tiles on first use, when I add this I’ll come back here and let you know if it helps with the speed (though in my case it is not a choropleth map).

I’ve also noticed when overlaying polygons from sf objects ontop of leaflet map tiles, that the boundaries themselves can take a long time to draw, so that might be something to check as well (though I don’t know of a good solution for that).

I haven’t tried using plotly for maps.