ecoscope.plotting#
Submodules#
Package Contents#
- class ecoscope.plotting.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#
- class ecoscope.plotting.EcoPlotData(grouped, x_col='x', y_col='y', color_col=None, groupby_style=None, **style)[source]#
- grouped#
- x_col = 'x'#
- y_col = 'y'#
- color_col = None#
- groupby_style#
- style#
- ecoscope.plotting.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)
- ecoscope.plotting.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]#
- ecoscope.plotting.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)
line_kwargs (dict)
layout_kwargs (dict)
- ecoscope.plotting.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.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)