Reputation: 17
New to Python and I have built a visualization using the following code:
df=pd.read_csv
fig=px.scatter_mapbox(df, lat='Latitude',
lon='Longitude',
hover_name='Combined_Key',
size='Confirmed',
mapbox_style='stamen-terrain',
zoom=10,
size_max=100)
However, I want to change the color of the bubbles from purple/yellow to an alternative color. Please can you let me know how I can change this?
Upvotes: 0
Views: 371
Reputation: 31166
https://plotly.github.io/plotly.py-docs/generated/plotly.express.scatter_mapbox.html
color_continuous_scale
https://plotly.com/python/builtin-colorscales/range_color
to bound values so color scale is not dominated by fat tails
df = pd.read_csv('http://coronavirus-resources.esri.com/datasets/628578697fb24d8ea4c32fa0c5ae1843_0.csv?outSR={"latestWkid":4326,"wkid":4326}')
# df=pd.read_csv("/content/COVID-19_Cases_US.csv")
fig=px.scatter_mapbox(df, lat='Lat',
lon='Long_',
hover_name='Combined_Key',
size='Confirmed',
color='Deaths',
mapbox_style='stamen-terrain',
color_continuous_scale="ylorrd",
range_color=[df["Deaths"].quantile(.5),df["Deaths"].quantile(.95)],
zoom=4,
size_max=40)
fig.update_layout(
mapbox_style="white-bg",
mapbox_layers=[
{
"below": 'traces',
"sourcetype": "raster",
"sourceattribution": "United States Geological Survey",
"source": [
"https://basemap.nationalmap.gov/arcgis/rest/services/USGSImageryOnly/MapServer/tile/{z}/{y}/{x}"
]
}
])
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig.show()
Upvotes: 2
Reputation: 11
try with these codes.may be it will help you:
px.scatter_mapbox(df, lat='Lat',lon='Long_',hover_name='Combined_Key',size='Confirmed', color='Deaths',mapbox_style='stamen-terrain',zoom=4,size_max=40,cmap="Blues",alpha=0.4,edgecolors="grey",linewidth=2))
Upvotes: 0