简体   繁体   中英

color effect on map (python plotly)

I create a basemap for US and want to fill in color with temperature value.

I want to fill the map with the color effect like the following picture.

But now I could only hand code the color value like 'red','orange' and 'purple' and could not get the effect.

Any suggestion to help me to start the search? Thanks.

在此处输入图片说明

Looks at this example . On this step you can change colorscale parameter (and color changed on whole basemap).

I suggest you for first look at this forum answer and choose what colorscale you want the most (based on that page ). Such colorscale="Jet" .

Next, if that did not what you are looking for, then you can create a custom colorscale , specifying what color you want at each steps of colorscale.

Such this:

colorscale=[[0, 'rgb(166,206,227)'],[0.25, 'rgb(31,120,180)'],[0.45, 'rgb(178,223,138)']\
,[0.65, 'rgb(51,160,44)'],[0.85, 'rgb(251,154,153)'],[1, 'rgb(227,26,28)']]

But be warned! If you trying to update basemap example from plotly docs, check zmin and zmax . In example zmin=-5 and zmax=5 , so changed steps in custom colorscale if want custom colorscale:

colorscale=[[-5, 'rgb(166,206,227)'], [-3, 'rgb(31,120,180)'], [-1, 'rgb(178,223,138)']\
    , [1, 'rgb(51,160,44)'], [3, 'rgb(251,154,153)'], [5, 'rgb(227,26,28)']]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM