ecoscope.plotting.plot#
Module Contents#
- class ecoscope.plotting.plot.EcoPlotData(grouped, x_col='x', y_col='y', color_col=None, groupby_style=None, **style)[source]#
- Parameters:
grouped (pandas.core.groupby.generic.DataFrameGroupBy)
x_col (str)
y_col (str)
color_col (str | None)
groupby_style (dict | None)
- grouped#
- x_col = 'x'#
- y_col = 'y'#
- color_col = None#
- groupby_style#
- style#
- ecoscope.plotting.plot.ecoplot(data, title='', out_path=None, subplot_height=100, subplot_width=700, vertical_spacing=0.001, annotate_name_pos=(0.01, 0.99), y_title_2=None, layout_kwargs=None, tickformat='%b-%Y', **make_subplots_kwargs)[source]#
- Parameters:
data (list[EcoPlotData])
title (str)
out_path (str | None)
subplot_height (int)
subplot_width (int)
vertical_spacing (float)
annotate_name_pos (Tuple[float, float])
y_title_2 (str | None)
layout_kwargs (dict | None)
tickformat (str)
- Return type:
plotly.graph_objs.Figure
- ecoscope.plotting.plot.add_seasons(fig, season_df)[source]#
- Parameters:
fig (plotly.graph_objs.Figure)
season_df (pandas.DataFrame)
- Return type:
plotly.graph_objs.Figure
- ecoscope.plotting.plot.mcp(relocations)[source]#
- Parameters:
relocations (ecoscope.Relocations)
- Return type:
plotly.graph_objs.Figure
- ecoscope.plotting.plot.nsd(relocations)[source]#
- Parameters:
relocations (ecoscope.Relocations)
- Return type:
plotly.graph_objs.Figure
- ecoscope.plotting.plot.speed(trajectory)[source]#
- Parameters:
trajectory (ecoscope.Trajectory)
- Return type:
plotly.graph_objs.Figure
- ecoscope.plotting.plot.plot_seasonal_dist(ndvi_vals, cuts, bandwidth=0.05, output_file=None)[source]#
- Parameters:
ndvi_vals (pandas.Series)
cuts (list[float])
bandwidth (float)
output_file (str | None)
- Return type:
plotly.graph_objs.Figure
- ecoscope.plotting.plot.stacked_bar_chart(data, agg_function, stack_column, layout_kwargs=None)[source]#
Creates a stacked bar chart from the provided EcoPlotData object :param data: The data to plot, counts categorical data.y_col values for data.x_col :type data: ecoscope.Plotting.EcoPlotData :param agg_function: The pandas.Dataframe.aggregate() function to run ie; ‘count’, ‘sum’ :type agg_function: str :param stack_column: The name of the column in the data to build stacks from, should be categorical :type stack_column: str :param layout_kwargs: Additional kwargs passed to plotly.go.Figure(layout) :type layout_kwargs: dict
- Returns:
fig – The plotly bar chart
- Return type:
plotly.graph_objects.Figure
- Parameters:
data (EcoPlotData)
agg_function (str)
stack_column (str)
layout_kwargs (dict | None)
- class ecoscope.plotting.plot.BarConfig[source]#
A class to represent configs for an individual bar in a bar chart. Attributes: ———- column : str
The name of the column to be used for the bar.
- agg_funcstr
The aggregation function to be applied to the column data.
- labelstr
The label for the bar.
- styledict, optional
A dictionary containing style options for the individual bar (default is None).
- column: str#
- agg_func: str#
- label: str#
- style: dict | None = None#
- ecoscope.plotting.plot.bar_chart(data, bar_configs, category, layout_kwargs=None)[source]#
Creates a bar chart from the provided dataframe :param data: The data to plot :type data: pd.DataFrame :param bar_configs: Specification for the bar chart, including labels, columns, and functions for aggregation. :type bar_configs: a list of BarConfigs :param category: The column name in the dataframe to group by and use as the x-axis categories. :type category: str :param layout_kwargs: Additional kwargs passed to plotly.go.Figure(layout) :type layout_kwargs: dict
- Returns:
fig – The plotly bar chart
- Return type:
plotly.graph_objects.Figure
- Parameters:
data (pandas.DataFrame)
bar_configs (list[BarConfig])
category (str)
layout_kwargs (dict | None)
- ecoscope.plotting.plot.line_chart(data, x_column, y_column, category_column=None, line_kwargs=None, layout_kwargs=None)[source]#
Creates a line chart from the provided dataframe :param data: The data to plot :type data: pd.DataFrame :param x_column: The name of the dataframe column to pull x-axis values from :type x_column: str :param y_column: The name of the dataframe column to pull y-axis values from :type y_column: str :param category_column: The column name in the dataframe to group by and use as separate traces. :type category_column: str :param line_kwargs: Line style kwargs passed to plotly.go.Scatter() :type line_kwargs: dict :param layout_kwargs: Additional kwargs passed to plotly.go.Figure(layout) :type layout_kwargs: dict
- Returns:
fig – The plotly line chart
- Return type:
plotly.graph_objects.Figure
- Parameters:
data (pandas.DataFrame)
x_column (str)
y_column (str)
category_column (str | None)
line_kwargs (dict | None)
layout_kwargs (dict | None)
- ecoscope.plotting.plot.pie_chart(data, value_column, label_column=None, color_column=None, style_kwargs=None, layout_kwargs=None)[source]#
Creates a pie chart from the provided dataframe :param data: The data to plot :type data: pd.Dataframe :param value_column: The name of the dataframe column to pull slice values from
- If the column contains non-numeric values, it is assumed to be categorical
and the pie slices will be a count of the occurrences of the category
- Parameters:
label_column (str) – The name of the dataframe column to label slices with, required if the data in value_column is numeric
style_kwargs (dict) – Additional style kwargs passed to go.Pie()
layout_kwargs (dict) – Additional kwargs passed to plotly.go.Figure(layout)
data (pandas.DataFrame)
value_column (str)
color_column (str | None)
- Returns:
fig – The plotly bar chart
- Return type:
plotly.graph_objects.Figure
- ecoscope.plotting.plot.draw_historic_timeseries(df, current_value_column, current_value_title, historic_min_column=None, historic_max_column=None, historic_band_title='Historic Min-Max', historic_mean_column=None, historic_mean_title='Historic Mean', layout_kwargs=None, upper_lower_band_style=None, historic_mean_style=None, current_value_style=None, time_column='img_date')[source]#
Creates a timeseries plot compared with historical values :param df: The data to plot :type df: pd.Dataframe :param current_value_column: The name of the dataframe column to pull slice values from :type current_value_column: str :param current_value_title: The title shown in the plot legend for current value :type current_value_title: str :param historic_min_column: The name of the dataframe column to pull historic min values from.
historic_min_column and historic_max_column should exist together.
- Parameters:
historic_max_column (str) – The name of the dataframe column to pull historic max values from. historic_min_column and historic_max_column should exist together.
historic_band_title (str) – The title shown in the plot legend for historic band
historic_mean_column (str) – The name of the dataframe column to pull historic mean values from
historic_mean_title (str) – The title shown in the plot legend for historic mean values
layout_kwargs (dict) – Additional kwargs passed to plotly.go.Figure(layout)
time_column (str) – The time column. Default: “img_date”
df (pandas.DataFrame)
current_value_column (str)
current_value_title (str)
historic_min_column (str)
upper_lower_band_style (dict | None)
historic_mean_style (dict | None)
current_value_style (dict | None)
- Returns:
fig – The plotly bar chart
- Return type:
plotly.graph_objects.Figure