Plotting¶
This module contains plotting methods.
We provide some high-level plotting methods which work on the outputs of different srai
components. By default, folium
based functions are exposed within plotting
module. Additional
functions can be found in srai.plotting.plotly_wrapper
module.
Functions¶
srai.plotting.plot_all_neighbourhood ¶
plot_all_neighbourhood(
regions_gdf: gpd.GeoDataFrame,
region_id: IndexType,
neighbourhood: Neighbourhood[IndexType],
neighbourhood_max_distance: int = 100,
tiles_style: str = "OpenStreetMap",
height: Union[str, float] = "100%",
width: Union[str, float] = "100%",
colormap: Union[str, list[str]] = px.colors.sequential.Agsunset_r,
map: Optional[folium.Map] = None,
show_borders: bool = True,
) -> folium.Map
Plot full neighbourhood on a map using Folium library.
PARAMETER | DESCRIPTION |
---|---|
regions_gdf
|
Region indexes and geometries to plot.
TYPE:
|
region_id
|
Center
TYPE:
|
neighbourhood
|
TYPE:
|
neighbourhood_max_distance
|
Max distance for rendering neighbourhoods. Neighbours farther away won't be coloured, and will be left as "other" regions. Defaults to 100.
TYPE:
|
tiles_style
|
Map style background. For more styles, look at tiles param at https://geopandas.org/en/stable/docs/reference/api/geopandas.GeoDataFrame.explore.html. Defaults to "OpenStreetMap".
TYPE:
|
height
|
Height of the plot. Defaults to "100%".
TYPE:
|
width
|
Width of the plot. Defaults to "100%".
TYPE:
|
colormap
|
Colormap to apply to the neighbourhoods.
Defaults to
TYPE:
|
map
|
Existing map instance on which to draw the plot. Defaults to None.
TYPE:
|
show_borders
|
Whether to show borders between regions or not. Defaults to True.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Map
|
folium.Map: Generated map. |
Source code in srai/plotting/folium_wrapper.py
srai.plotting.plot_neighbours ¶
plot_neighbours(
regions_gdf: gpd.GeoDataFrame,
region_id: IndexType,
neighbours_ids: set[IndexType],
tiles_style: str = "OpenStreetMap",
height: Union[str, float] = "100%",
width: Union[str, float] = "100%",
map: Optional[folium.Map] = None,
show_borders: bool = True,
) -> folium.Map
Plot neighbours on a map using Folium library.
PARAMETER | DESCRIPTION |
---|---|
regions_gdf
|
Region indexes and geometries to plot.
TYPE:
|
region_id
|
Center
TYPE:
|
neighbours_ids
|
List of neighbours to highlight.
TYPE:
|
tiles_style
|
Map style background. For more styles, look at tiles param at https://geopandas.org/en/stable/docs/reference/api/geopandas.GeoDataFrame.explore.html. Defaults to "OpenStreetMap".
TYPE:
|
height
|
Height of the plot. Defaults to "100%".
TYPE:
|
width
|
Width of the plot. Defaults to "100%".
TYPE:
|
map
|
Existing map instance on which to draw the plot. Defaults to None.
TYPE:
|
show_borders
|
Whether to show borders between regions or not. Defaults to True.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Map
|
folium.Map: Generated map. |
Source code in srai/plotting/folium_wrapper.py
srai.plotting.plot_numeric_data ¶
plot_numeric_data(
regions_gdf: gpd.GeoDataFrame,
data_column: str,
embedding_df: Optional[Union[pd.DataFrame, gpd.GeoDataFrame]] = None,
tiles_style: str = "CartoDB positron",
height: Union[str, float] = "100%",
width: Union[str, float] = "100%",
colormap: Union[str, list[str]] = px.colors.sequential.Sunsetdark,
map: Optional[folium.Map] = None,
show_borders: bool = False,
opacity: float = 0.8,
) -> folium.Map
Plot numerical data within regions shapes using Folium library.
PARAMETER | DESCRIPTION |
---|---|
regions_gdf
|
Region indexes and geometries to plot.
TYPE:
|
embedding_df
|
Region indexes and numerical data to plot. If not provided, will use regions_gdf.
TYPE:
|
data_column
|
Name of the column used to colour the regions.
TYPE:
|
tiles_style
|
Map style background. For more styles, look at tiles param at https://geopandas.org/en/stable/docs/reference/api/geopandas.GeoDataFrame.explore.html. Defaults to "CartoDB positron".
TYPE:
|
height
|
Height of the plot. Defaults to "100%".
TYPE:
|
width
|
Width of the plot. Defaults to "100%".
TYPE:
|
colormap
|
Colormap to apply to the regions. Defaults to px.colors.sequential.Sunsetdark.
TYPE:
|
map
|
Existing map instance on which to draw the plot. Defaults to None.
TYPE:
|
show_borders
|
Whether to show borders between regions or not. Defaults to False.
TYPE:
|
opacity
|
Opacity of coloured regions.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Map
|
folium.Map: Generated map. |
Source code in srai/plotting/folium_wrapper.py
srai.plotting.plot_regions ¶
plot_regions(
regions_gdf: gpd.GeoDataFrame,
tiles_style: str = "OpenStreetMap",
height: Union[str, float] = "100%",
width: Union[str, float] = "100%",
colormap: Union[str, list[str]] = px.colors.qualitative.Bold,
map: Optional[folium.Map] = None,
show_borders: bool = True,
) -> folium.Map
Plot regions shapes using Folium library.
PARAMETER | DESCRIPTION |
---|---|
regions_gdf
|
Region indexes and geometries to plot.
TYPE:
|
tiles_style
|
Map style background. For more styles, look at tiles param at https://geopandas.org/en/stable/docs/reference/api/geopandas.GeoDataFrame.explore.html. Defaults to "OpenStreetMap".
TYPE:
|
height
|
Height of the plot. Defaults to "100%".
TYPE:
|
width
|
Width of the plot. Defaults to "100%".
TYPE:
|
colormap
|
Colormap to apply to the regions.
Defaults to
TYPE:
|
map
|
Existing map instance on which to draw the plot. Defaults to None.
TYPE:
|
show_borders
|
Whether to show borders between regions or not. Defaults to True.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Map
|
folium.Map: Generated map. |