Density Heatmap - output changes for same point between pannning

Hello,

First post, so here goes nothing!

Is there a way to set the random seed on the mapbox density heatmap (https://plotly.com/python/mapbox-density-heatmaps/)?

The reason I ask is that I notice that when I pan on a heatmap, the density changes. Below are some screenshot examples, the only difference being I panned between screenshots (not zoom). I assume it’s a random seed thing? If not, is there a way to ensure a consistent output?

map1.PNG
map2

Thanks,
Rachel

Turns out when I don’t set the radius then I don’t have this problem!

Hi @r4ch45 welcome to the forum! Unfortunately I can’t reproduce the issue with the documentation examples, even when setting the radius. Any chance that you could share some minimal code and data reproducing the issue? Could you also tell us which version of plotly.py you are using?

Hi Emmanuelle,

Sure thing - thanks! The documentation example has the same issue for me when the radius is reduced from 10, and you zoom into an area. I’m on version 4.6.0.

import pandas as pd
quakes = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/earthquakes-23k.csv')

import plotly.graph_objects as go
fig = go.Figure(go.Densitymapbox(lat=quakes.Latitude, lon=quakes.Longitude, z=quakes.Magnitude,
                                 radius=3))
fig.update_layout(mapbox_style="stamen-terrain", mapbox_center_lon=180)
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig.show()

heatmap1
heatmap2

Thanks,
Rachel

Hum still can’t reproduce (On Firefox). Which browser are you using? Did you try with another browser (you can use the documentation examples with the binder links if you don’t want to set up the notebook with another browser)?

Damn, I’m on Chrome 80.0.3987.163 (on a locked down machine without Firefox annoyingly). Ran a binder from the docs on Chrome with radius=3 for fun and still getting same issue. Same issue on IE but not sure that says much.

wow this is weird because I don’t get the issue on Chrome (with radius=3). It’d be great if someone else here could give it a try and see if they can reproduce the issue.

1 Like

Hi, I’m on the same Chrome version (80.0.3987.163) and can see a similar issue with a radius below 3.

My display settings are 1920 by 1280, at 150% scaling - and it looks like the issue is more visible at 100% scaling.

Cheers,
Connor

2 Likes