Code Duplication    Length = 21-24 lines in 2 locations

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

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

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

@@ 1007-1030 (lines=24) @@
1004
    return df_profile_merge.loc[:, columns]
1005
1006
1007
def plot_heat_supply(resulting_capacities):
1008
    from matplotlib import pyplot as plt
1009
1010
    mv_grids = db.select_geodataframe(
1011
        """
1012
        SELECT * FROM grid.egon_mv_grid_district
1013
        """,
1014
        index_col="bus_id",
1015
    )
1016
1017
    for c in ["CHP", "heat_pump"]:
1018
        mv_grids[c] = (
1019
            resulting_capacities[resulting_capacities.carrier == c]
1020
            .set_index("mv_grid_id")
1021
            .capacity
1022
        )
1023
1024
        fig, ax = plt.subplots(1, 1)
1025
        mv_grids.boundary.plot(linewidth=0.2, ax=ax, color="black")
1026
        mv_grids.plot(
1027
            ax=ax,
1028
            column=c,
1029
            cmap="magma_r",
1030
            legend=True,
1031
            legend_kwds={
1032
                "label": f"Installed {c} in MW",
1033
                "orientation": "vertical",