Plotly.py: Figure factory: Plot a scalar field with geographical coordinates on map with projection

Created on 16 Mar 2017  Â·  6Comments  Â·  Source: plotly/plotly.py

I have an array of global temperatures and associated longitude and latitude coordinates arrays. I would like to plot the temperatures as a heatmap on a map with custom projection and showing coastlines.
A working code example using matplotlib is:

import matplotlib.pyplot as plt
import cartopy.crs as ccrs

f, ax = plt.subplots(subplot_kw={'projection': ccrs.Robinson()})
p = ax.pcolormesh(longitude, latitude, temperature, cmap='RdBu_r', transform=ccrs.PlateCarree())
ax.coastlines()
f.colorbar(p, orientation='horizontal')

The output figure from code block above is (data available here):
map

At the moment I was only able to use plotly for a simple heatmap with the following code:

from plotly.offline import iplot
import plotly.graph_objs as go

layout = go.Layout(geo={'projection': {'type': 'robinson'}})
data = go.Heatmap(x=longitude, y=latitude, z=temperature)

fig = go.Figure(data=[data], layout=layout)
iplot(fig)

As next figure shows, main issues are:

  • the projection is not working;

  • no coastlines are shown.
    heatmap

enhancement ♥ NEEDS SPON$OR

All 6 comments

Would also love something similar!

You can plot both heatmap and contour plots on maps. Take a look here: https://plot.ly/~Dreamshot/9147 or visit this user (Dreamshot) Plotly profile for more examples.

Thanks! Will take a look :)

Although it does not seem to support mapping per se. I mean, the data are on a lat-lon coordinates, but what if we want to change the projection? I don't see a proper support for maps right out of the box (or at least without creating a unique map for each use case).

A geographic heatmap figure factory would be really nice!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

binaryfunt picture binaryfunt  Â·  5Comments

jonmmease picture jonmmease  Â·  3Comments

EmilienDupont picture EmilienDupont  Â·  4Comments

suciokhan picture suciokhan  Â·  3Comments

AmazingSean picture AmazingSean  Â·  4Comments