plotly / plotly/plotly.R

Unable to style colorbar in density mapbox

Open
#2,199 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
2.7k
Forks
641
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the R densitymapbox example at https://plotly.com/r/mapbox-density-heatmaps/ with the issue's code and inspect how coloraxis and its layout options are handled. Done means the coloraxis color, colorbar visibility, and colorbar position can be styled as requested without breaking the plot.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data-visualization
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.