Skip to content

Figure factory: Plot a scalar field with geographical coordinates on map with projection  #715

Open
@ghost

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):
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3backlogfeaturesomething new

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions