ecoscope.plotting.plot ====================== .. py:module:: ecoscope.plotting.plot Module Contents --------------- .. py:class:: EcoPlotData(grouped, x_col='x', y_col='y', color_col=None, groupby_style=None, **style) .. py:attribute:: grouped .. py:attribute:: x_col :value: 'x' .. py:attribute:: y_col :value: 'y' .. py:attribute:: color_col :value: None .. py:attribute:: groupby_style .. py:attribute:: style .. py:function:: 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) .. py:function:: add_seasons(fig, season_df) .. py:function:: mcp(relocations) .. py:function:: nsd(relocations) .. py:function:: speed(trajectory) .. py:function:: plot_seasonal_dist(ndvi_vals, cuts, bandwidth=0.05, output_file=None) .. py:function:: stacked_bar_chart(data, agg_function, stack_column, layout_kwargs = None) 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 :rtype: plotly.graph_objects.Figure .. py:class:: BarConfig 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_func : str The aggregation function to be applied to the column data. label : str The label for the bar. style : dict, optional A dictionary containing style options for the individual bar (default is None). .. py:attribute:: column :type: str .. py:attribute:: agg_func :type: str .. py:attribute:: label :type: str .. py:attribute:: style :type: dict :value: None .. py:function:: bar_chart(data, bar_configs, category, layout_kwargs = None) 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 :rtype: plotly.graph_objects.Figure .. py:function:: line_chart(data, x_column, y_column, category_column = None, line_kwargs = None, layout_kwargs = None) 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 :rtype: plotly.graph_objects.Figure .. py:function:: pie_chart(data, value_column, label_column = None, color_column = None, style_kwargs = None, layout_kwargs = None) 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 :type value_column: str :param label_column: The name of the dataframe column to label slices with, required if the data in value_column is numeric :type label_column: str :param style_kwargs: Additional style kwargs passed to go.Pie() :type style_kwargs: dict :param layout_kwargs: Additional kwargs passed to plotly.go.Figure(layout) :type layout_kwargs: dict :returns: **fig** -- The plotly bar chart :rtype: plotly.graph_objects.Figure .. py:function:: 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') 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. :type historic_min_column: str :param historic_max_column: The name of the dataframe column to pull historic max values from. historic_min_column and historic_max_column should exist together. :type historic_max_column: str :param historic_band_title: The title shown in the plot legend for historic band :type historic_band_title: str :param historic_mean_column: The name of the dataframe column to pull historic mean values from :type historic_mean_column: str :param historic_mean_title: The title shown in the plot legend for historic mean values :type historic_mean_title: str :param layout_kwargs: Additional kwargs passed to plotly.go.Figure(layout) :type layout_kwargs: dict :param time_column: The time column. Default: "img_date" :type time_column: str :returns: **fig** -- The plotly bar chart :rtype: plotly.graph_objects.Figure