Reputation: 301
I currently have the following code:
fig = px.scatter_mapbox(coefs_df,
lat="LATITUDE",
lon="LONGITUDE",
hover_name = "NAME",
color = "coef",
zoom=2,
mapbox_style = "carto-positron")
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig.show()
That shows: It is hard to see, so I want to change the color bar to something like: How do I change the color bar so that I have high red, middle white, and low black?
Upvotes: 1
Views: 2879
Reputation: 1858
Many Plotly Express functions accept a color_continuous_scale
argument and many trace types have a colorscale attribute in their schema. Plotly comes with a large number of built-in continuous color scales, which can be referred to in Python code.
These are the built-in continuous color scales:
aggrnyl agsunset blackbody bluered blues blugrn bluyl brwnyl
bugn bupu burg burgyl cividis darkmint electric emrld
gnbu greens greys hot inferno jet magenta magma
mint orrd oranges oryel peach pinkyl plasma plotly3
pubu pubugn purd purp purples purpor rainbow rdbu
rdpu redor reds sunset sunsetdark teal tealgrn turbo
viridis ylgn ylgnbu ylorbr ylorrd algae amp deep
dense gray haline ice matter solar speed tempo
thermal turbid armyrose brbg earth fall geyser prgn
piyg picnic portland puor rdgy rdylbu rdylgn spectral
tealrose temps tropic balance curl delta oxy edge
hsv icefire phase twilight mrybm mygbm
You can get what you want with the following schema:
continuous_color_scale="rdgy"
In your case, you also need to "reverse" colors schema.
You can reverse a built-in color scale by appending _r
to its name.
continuous_color_scale="rdgy_r"
Upvotes: 2
Reputation: 25
the color depends on the points you put on the map, if you put red and blue points the bar will be red and blue
Upvotes: 0