Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Single color plotly map

How can I render a plotly map with only a single color. In the example below, I would like the fill for all states to be red, or #FF0000.

library(plotly)
library(tidyverse)

dat <- data.frame(state = state.abb)

plot_ly(dat,
        type = "choropleth",
        locationmode = 'USA-states',
        locations = ~state) %>% 
  add_trace(color = "red") %>%
  layout(geo = list(
    projection = list(
      type = "albers usa")))

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

From what I understand of the plotly documentation this is a way to achive it (cloropleth is kind of heatmap but you want one color for all):

library(plotly)

dat <- data.frame(state = state.abb)

plot_ly(dat,
        type = "scattergeo",
        mode = 'none',
        locationmode = 'USA-states',
        locations = ~state) %>%
 layout(geo = list(landcolor = "#FF0000",
                   showland = TRUE,
                   projection = list(type = "albers usa")))

enter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading