Visualization
- climate_resilience.visualize.get_site_markers(site: pandas.core.series.Series, icon_name: str, ipl_map: leafmap.leafmap.Map, feature: str) None
Same as plot_site_on_map() but returns the marker instead of plotting it on the map. Also provides a tooltip at the markers showing the values and site ID.
- Parameters
site (pd.Series) – Site to be plotted on the map.
icon_name (str) – Icon to be used as marker on the map.
ipl_map (leafmap.Map) – Map on which the site markers are added.
feature (str) – Feature based on which the markers are generated.
- climate_resilience.visualize.plot_boxplot(data: pandas.core.frame.DataFrame, x_feature: str, y_feature: str, hue_feature: str, hue_order: Optional[List[str]] = None, colors: Optional[List[str]] = None, x_label: Optional[str] = None, y_label: Optional[str] = None, plot_title: str = 'Box Plot', figsize: Tuple[int] = (12, 6), output_filename: Optional[str] = None) matplotlib.pyplot.axes
Create boxplot using the provided data.
- Parameters
data (pd.DataFrame) – Data that is used to plot the boxplots.
x_feature (str) – Feature within the data that is plotted on the x-axis.
y_feature (str) – Feature within the data that is plotted on the y-axis.
hue_feature (str) – Feature within the data that is used as the third dimension categorical levels.
hue_order (List[str]) – The order in which the categorical levels are to be plotted. Defaults to None. Levels are infered from the data argument automatically if this argument is None.
colors (List[str]) – List of colors to be used for each categorical level. Defaults to None.
x_label (str, optional) – X-axis label. Defaults to None. The ‘x_feature’ argument is used if this argument is not provided.
y_label (str, optional) – Y-axis label. Defaults to None. The ‘y_feature’ argument is used if this argument is not provided.
plot_title (str, optional) – Title of the plot. Defaults to ‘Box Plot’.
figsize (Tuple[int], optional) – Figure canvas size. Defaults to (12,6).
output_filename (str, optional) – Name of the output PNG file. Defaults to None. The output file is not generated in this case.
- Returns
- Return the plot object axes. This object can be used to
further add plot components if required by the user.
- Return type
plt.axes
- climate_resilience.visualize.plot_histogram(sites: pandas.core.frame.DataFrame, features: List[str], n_bins: int = 10, bins: Optional[List[float]] = None, plot_title: str = 'Histogram', figsize: Tuple[int] = (12, 6), xlabels: Optional[List[str]] = None, colors: Optional[List[str]] = None) Tuple[matplotlib.pyplot.figure, matplotlib.pyplot.axes]
Plot histogram between specified bins for the select features of the sites data frame.
- Parameters
sites (pd.DataFrame) – Data Frame containing all the site information.
features (List[str]) – Features of interest.
n_bins (int) – Number of histogram bins. Will be ignored if ‘bins’ argument is passed. Defaults to 10.
bins (List[float]) – Custom bins for the histogram. Defaults to None. ‘n_bins’ argument is used in this case.
plot_title (str) – Title of the resulting plot.
figsize (Tuple[int]) – Size of the output plot. Format: (width, height).
xlabels (List[str]) – Custom labels in place of x-axis bin range values. Defaults to None. Original bin values are used in this case.
colors (List["str"]) – List of colors for each data vector. Must match the number features listed. Defaults to None. Matplotlib default colors are used in this case.
- Returns
- Returns the figure and axes for the
generated plot.
- Return type
Tuple[plt.figure, plt.axes]
- climate_resilience.visualize.plot_map(sites: pandas.core.frame.DataFrame, feature: str, colors: List[str], scale_range: Optional[List[float]] = None, icon_name: str = 'umbrella', map_center: List[float] = [39.0119, - 98.4842], map_zoom: int = 4, plot_colorbar: bool = True, colorbar_label: str = 'Colorbar', colorbar_min: Optional[float] = None, colorbar_max: Optional[float] = None, output_map_name: Optional[str] = None) leafmap.leafmap.Map
Plot and mark each site on a map.
The markers that are generated in white color either lie outside the range specified in ‘scale_range’ OR have nan values.
- Parameters
sites (pd.DataFrame) – Data Frame containing all the site information.
feature (str) – Feature of interest.
colors (List[str]) – List of colors to be used as markers. The scale_range is divided into number of colors specified.
scale_range (List[float], optional) – Range of the scale. Expects a min and max value to specify the range. Defaults to None. Min and Max value of the sites features are used in this case.
icon_name (str, optional) – Name of the Awesome icon that is used as marker for the sites on the map. Defaults to ‘umbrella’.
map_center (List[float], optional) – Marks the initial center coordinates of the map. Defaults to [39.0119, -98.4842].
map_zoom (int, optional) – Marks the intial zoom level in the map. Defaults to 4.
plot_colorbar (bool, optional) – Boolean flag to spacify if the colorbar is to be plotted in the map. Defaults to True.
colorbar_label (str, optional) – Caption for the colorbar. Defaults to ‘Colorbar’.
colorbar_min (float, optional) – Minimum value label in the color bar. Defaults to None. Values are taken from scale_range in this case.
colorbar_max (float, optional) – Maximum value label in the color bar. Defaults to None. Values are taken from scale_range in this case.
output_map_name (str, optional) – Name/Path of the output file. Must be an HTML file. Defaults to None. The output file is not generated in the default case.
- Returns
- Returns the map that is generated using all the specified
configurations.
- Return type
leafmap.Map
- climate_resilience.visualize.plot_site_on_map(site: pandas.core.series.Series, icon_name: str, ipl_map: leafmap.leafmap.Map, feature: str) None
Plot a single site on the map. Also provides a tooltip at the markers showing the values and site ID.
- Parameters
site (pd.Series) – Site to be plotted on the map.
icon_name (str) – Icon to be used as marker on the map.
ipl_map (leafmap.Map) – Map on which the site markers are added.
feature (str) – Feature based on which the markers are generated.