DJC
DJC

Reputation: 1611

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

Upvotes: 0

Views: 220

Answers (1)

DPH
DPH

Reputation: 4344

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

Upvotes: 2

Related Questions