Gridded numpy arrays¶
This example demonstrates how to plot numpy arrays of data on a map, given the longitude and latitude arrays which describe each point.
[1]:
import numpy as np
import earthkit.plots
data = np.random.rand(15, 30)
y = np.linspace(-90, 90, 15)
x = np.linspace(-180, 180, 30)
We can plot this as grid cells:
[2]:
chart = earthkit.plots.Map()
chart.grid_cells(data, x=x, y=y)
chart.coastlines(color="white")
chart.gridlines()
chart.legend(label="")
chart.show()
Or as isobands (smooth contours):
[3]:
chart = earthkit.plots.Map()
chart.contourf(data, x=x, y=y)
chart.coastlines(color="white")
chart.gridlines()
chart.legend(label="")
chart.show()
Or as a point cloud:
[4]:
chart = earthkit.plots.Map()
chart.point_cloud(data, x=x, y=y)
chart.coastlines()
chart.gridlines()
chart.legend(label="")
chart.show()
You can of course also plot your data on any projection:
[5]:
chart = earthkit.plots.Map(crs="Robinson")
chart.grid_cells(data, x=x, y=y)
chart.coastlines(color="white")
chart.gridlines()
chart.legend(label="")
chart.show()