Heat map from dictionary

0

I have a dictionary and I would like to create a map of heat or heatmap or densitymap of specific values. I only manage to plot the points but not the heat map. This is what I have.

for id,msj in diccionario.items():
    pylab.plot(msj['Longitud'],msj['Latitud'],'.')

With the above it works perfectly and I can see the figure of all the plotted points, but what I need is a heat map, I have tried this, but it does not work.

for id,msj in diccionario.items():
    plt.hexbin(msj['Longitud'],msj['Latitud'])

msj [length] and msj [latitude] are lists. The error I get is:

  

ValueError: First argument must be a sequence

Any ideas?

Maybe there is some other way to create a heat map, I do not mind using another method or library.

EDIT:

I have solved it by using two variables, lon and lat with this code:

lon=[]
lat=[]
for id,msj in diccionario.items():
    lon.append(msj['Longitud'])
    lat.append(msj['Latitud'])
plt.hexbin(lon,lat)

I've tried using hist2d too and I get something like this.

Is there any way to get something "nicer"? of the type this:

    
asked by Juanca M 15.03.2017 в 12:35
source

1 answer

1

Have you seen this bookstore ?

Taken from the main page

import plotly.plotly as py
import plotly.graph_objs as go

data = [
    go.Heatmap(
        z=[[1, 20, 30],
           [20, 1, 60],
           [30, 60, 1]]
    )
]
py.iplot(data, filename='basic-heatmap')

Maybe you can make a matrix with the values of your lists lan and lon and then replace it with z in the object go.Heatmap

Without a minimum example, I can not provide a better answer, I'm sorry.

    
answered by 19.03.2017 в 13:27