def gen_dist(
        network,
        techs=None,
        snapshot=1,
        n_cols=3,
        gen_size=0.2,
        filename=None):
    """
    Generation distribution

    Parameters
    ----------
    network : PyPSA network container
        Holds topology of grid including results from powerflow analysis
    techs : dict
        type of technologies which shall be plotted
    snapshot : int
        snapshot
    n_cols : int
        number of columns of the plot
    gen_size : num
        size of generation bubbles at the buses
    filename : str
        Specify filename
        If not given, figure will be show directly
    """
    if techs is None:
        techs = network.generators.carrier.unique()
    else:
        techs = techs

    n_graphs = len(techs)
    n_cols = n_cols

    if n_graphs % n_cols == 0:
        n_rows = n_graphs // n_cols
    else:
        n_rows = n_graphs // n_cols + 1

    fig, axes = plt.subplots(nrows=n_rows, ncols=n_cols)

    size = 4

    fig.set_size_inches(size * n_cols, size * n_rows)

    for i, tech in enumerate(techs):
        i_row = i // n_cols
        i_col = i % n_cols

        ax = axes[i_row, i_col]

        gens = network.generators[network.generators.carrier == tech]
        gen_distribution = network.generators_t.p.mul(network.
                snapshot_weightings, axis=0)\
                [gens.index].loc[network.snapshots[snapshot]].groupby(
                        network.generators.bus).sum().reindex(
                                network.buses.index, fill_value=0.)

        network.plot(
            ax=ax,
            bus_sizes=gen_size * gen_distribution,
            line_widths=0.1)

        ax.set_title(tech)
    if filename is None:
        plt.show()
    else:
        plt.savefig(filename)
        plt.close()