Figure factory: Plot a scalar field with geographical coordinates on map with projection
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 18.8k
- Forks
- 2.8k
- Avg merge
- 16h 26m
- Merged PRs (30d)
- 21
Description
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):

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.

Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Begin with the supplied plotly.graph_objs Heatmap example and compare it with the matplotlib/cartopy behavior. The work is complete when longitude/latitude temperature data renders as a heatmap with the requested projection and visible coastlines.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- plotly, python
- Domain
- data-visualization
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100