Skip to content

Unable to style colorbar in density mapbox #2199

Open
@banamwana

Description

@banamwana

I am following the example given here: https://plotly.com/r/mapbox-density-heatmaps/

However, I am unable to change the color of the coloraxis (or use showscale = F or move the colorbar over on x).

The plot won't work unless coloraxis = 'coloraxis' is specified, and there doesn't seem to be a way to style the coloraxis.

# population density available from https://data.humdata.org/dataset/worldpop-population-density-for-haiti
pop_den <- read.csv(data_path)
plot_ly() %>% 
  add_trace(
    data = pop_den,  type = 'densitymapbox',  lat = ~Y,  lon = ~X,  z = ~Z,
    coloraxis = 'coloraxis',
    radius = 10) %>% 
  layout(
    mapbox = list(
      style = "carto-positron",
      zoom = 6.5,
      center = list(lon = -73.09, lat = 19.06),
      coloraxis = list(colorscale = "Grey", colorbar_x = 1.5)
      )
    )

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions