Implement discretely_colour in plotly for R

Hi All,

I am looking to create a choropleth map where the color is based on a categorical variable.

In python plotly, the discrete_colour function described here Choropleth maps in Python exactly meets my needs.

On this stack overflow thread (How to create a chloropleth map in R Plotly based on a Categorical variable? - Stack Overflow) it is mentioned in the comments that non-continuous legends for choropleths would be coming early 2020, but it is not currently available and I cannot find any related issues or release notes.

Thanks a lot in advance.

I can't seem to find a function by this name on that site.

Also note that there are several existing ways to approach a discrete cartogram in R. Probably the easiest to work with an sf object (say sf_dat), then you can do something like plot_ly(sf_dat, split = ~feature_id).

This won't be as performant as using the choropleth (choroplethmapbox) trace type. Off-hand I don't recall how to make discrete choropleths using these trace types, but I'm sure it's possible (you probably have to put each discrete level in it's own trace, which you can probably do via split).

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