switch_model/tools/graph/main.py
def graph_pie_chart(self, df, max_size=2500, ax=None):
        """
        Graphs the data from the dataframe to a map pie chart.
        The dataframe should have 3 columns, gen_load_zone, gen_type and value.
        """
        _, center_points = self._load_maps()

        # Scale the dataframe so the pie charts have the right size
        current_max_size = df.groupby("gen_load_zone")["value"].sum().max()
        df["value"] *= max_size / current_max_size

        if ax is None:
            ax = self._tools.get_axes()
        self._plot_states(ax)
        df = df.merge(center_points, on="gen_load_zone")

        assert not df["gen_type"].isnull().values.any()
        colors = self._tools.get_colors()
        for index, group in df.groupby(["gen_load_zone"]):
            x, y = group["geometry"].iloc[0].x, group["geometry"].iloc[0].y
            group_sum = group.groupby("gen_type")["value"].sum().sort_values()
            group_sum = group_sum[group_sum != 0].copy()

            tech_color = [colors[tech] for tech in group_sum.index.values]
            total_size = group_sum.sum()
            ratios = (group_sum / total_size).values
            GraphMapTools._pie_plot(x, y, ratios, tech_color, ax=ax, size=total_size)
        return ax

        Graphs the data from the dataframe to a map pie chart.
        The dataframe should have 3 columns, gen_load_zone, gen_type and value.
        
Graphs the data from the dataframe to a map pie chart.
The dataframe should have 3 columns, gen_load_zone, gen_type and value.
Graphs the data from the dataframe to a map pie chart . The dataframe should have 3 columns gen_load_zone gen_type and value .
def graph_pie_chart(self, df, max_size=2500, ax=None):
        _, center_points = self._load_maps()
        current_max_size = df.groupby("gen_load_zone")["value"].sum().max()
        df["value"] *= max_size / current_max_size
        if ax is None:
            ax = self._tools.get_axes()
        self._plot_states(ax)
        df = df.merge(center_points, on="gen_load_zone")
        assert not df["gen_type"].isnull().values.any()
        colors = self._tools.get_colors()
        for index, group in df.groupby(["gen_load_zone"]):
            x, y = group["geometry"].iloc[0].x, group["geometry"].iloc[0].y
            group_sum = group.groupby("gen_type")["value"].sum().sort_values()
            group_sum = group_sum[group_sum != 0].copy()
            tech_color = [colors[tech] for tech in group_sum.index.values]
            total_size = group_sum.sum()
            ratios = (group_sum / total_size).values
            GraphMapTools._pie_plot(x, y, ratios, tech_color, ax=ax, size=total_size)
        return ax
def graph_pie_chart ( self , df , max_size = 2500 , ax = None ) : _ , center_points = self . _load_maps ( ) current_max_size = df . groupby ( "gen_load_zone" ) [ "value" ] . sum ( ) . max ( ) df [ "value" ] *= max_size / current_max_size if ax is None : ax = self . _tools . get_axes ( ) self . _plot_states ( ax ) df = df . merge ( center_points , on = "gen_load_zone" ) assert not df [ "gen_type" ] . isnull ( ) . values . any ( ) colors = self . _tools . get_colors ( ) for index , group in df . groupby ( [ "gen_load_zone" ] ) : x , y = group [ "geometry" ] . iloc [ 0 ] . x , group [ "geometry" ] . iloc [ 0 ] . y group_sum = group . groupby ( "gen_type" ) [ "value" ] . sum ( ) . sort_values ( ) group_sum = group_sum [ group_sum != 0 ] . copy ( ) tech_color = [ colors [ tech ] for tech in group_sum . index . values ] total_size = group_sum . sum ( ) ratios = ( group_sum / total_size ) . values GraphMapTools . _pie_plot ( x , y , ratios , tech_color , ax = ax , size = total_size ) return ax
Graphs the data from the dataframe to a map pie chart.
Graphs the data from the dataframe to a map pie chart .
"""
        Graphs the data from the dataframe to a map pie chart.
        The dataframe should have 3 columns, gen_load_zone, gen_type and value.
        """ # Scale the dataframe so the pie charts have the right size
self
df
max_size
ax