plot_model

plot_model(demo, raster, timestep, cmap='viridis', legend=True, tiles='CartoDB positron')

Plots the demes and migration rates for a given timestep as an interactive map.

Parameters

Name Type Description Default
demo spaceprime.spDemography The demographic model to plot. required
raster rasterio.DatasetReader The raster dataset used to create the demes matrix(es). required
timestep int The index of the desired timestep to plot. required
cmap str The colormap to use for the deme sizes. Defaults to ‘viridis’. 'viridis'
legend bool Whether to show the color legend. Defaults to True. True
tiles str The basemap tiles to use. Defaults to “CartoDB positron”. 'CartoDB positron'

Returns

Type Description
folium.folium.Map An interactive plot of the demes and migration rates.

Example

raster = rasterio.open(“path/to/raster.tif”) # Plot the model at timestep 1 plot_model(demo, raster, 1)

Notes

Since this function returns a folium map object, you can further modify the map or save it to an HTML file with the folium library.