Code Duplication    Length = 21-24 lines in 2 locations

src/egon/data/datasets/heat_supply/district_heating.py 1 location

@@ 480-500 (lines=21) @@
477
    return df
478
479
480
def plot_heat_supply(resulting_capacities):
481
    from matplotlib import pyplot as plt
482
483
    district_heating_areas = select_district_heating_areas("eGon2035")
484
485
    for c in ["CHP", "solar_thermal_collector", "geo_thermal", "heat_pump"]:
486
        district_heating_areas[c] = (
487
            resulting_capacities[resulting_capacities.carrier == c]
488
            .set_index("district_heating_id")
489
            .capacity
490
        )
491
492
        fig, ax = plt.subplots(1, 1)
493
        district_heating_areas.boundary.plot(
494
            linewidth=0.2, ax=ax, color="black"
495
        )
496
        district_heating_areas.plot(
497
            ax=ax,
498
            column=c,
499
            cmap="magma_r",
500
            legend=True,
501
            legend_kwds={
502
                "label": f"Installed {c} in MW",
503
                "orientation": "vertical",

src/egon/data/datasets/heat_supply/individual_heating.py 1 location

@@ 1144-1167 (lines=24) @@
1141
    return df_profile_merge.loc[:, columns]
1142
1143
1144
def plot_heat_supply(resulting_capacities):
1145
    from matplotlib import pyplot as plt
1146
1147
    mv_grids = db.select_geodataframe(
1148
        """
1149
        SELECT * FROM grid.egon_mv_grid_district
1150
        """,
1151
        index_col="bus_id",
1152
    )
1153
1154
    for c in ["CHP", "heat_pump"]:
1155
        mv_grids[c] = (
1156
            resulting_capacities[resulting_capacities.carrier == c]
1157
            .set_index("mv_grid_id")
1158
            .capacity
1159
        )
1160
1161
        fig, ax = plt.subplots(1, 1)
1162
        mv_grids.boundary.plot(linewidth=0.2, ax=ax, color="black")
1163
        mv_grids.plot(
1164
            ax=ax,
1165
            column=c,
1166
            cmap="magma_r",
1167
            legend=True,
1168
            legend_kwds={
1169
                "label": f"Installed {c} in MW",
1170
                "orientation": "vertical",