Paths#
import pandas as pd
import hvplot.pandas # noqa
import cartopy.crs as ccrs
Paths are useful if you are plotting lines on a geographic map.
df = pd.DataFrame({"city": ["NY", "Delhi"], "lon": [-75, 77.23], "lat": [43, 28.61]})
Notice how the line in blue between New York and Delhi is not straight on a flat PlateCarree map, this is because the Geodetic coordinate system is a truly spherical coordinate system, where a line between two points is defined as the shortest path between those points on the globe rather than 2d Cartesian space.
common_kwargs = dict(
x="lon",
y="lat",
geo=True,
project=True,
projection=ccrs.GOOGLE_MERCATOR,
global_extent=True
)
shortest_path = df.hvplot.paths(color="blue", crs=ccrs.Geodetic(), tiles=True, **common_kwargs)
straight_path = df.hvplot.paths(color="grey", line_dash="dashed", **common_kwargs)
labels = df.hvplot.labels(text_color="black", text="city", **common_kwargs)
shortest_path * straight_path * labels
Example adapted from https://scitools.org.uk/cartopy/docs/latest/matplotlib/intro.html.
This web page was generated from a Jupyter notebook and not all
interactivity will work on this website.