def max_load(network, boundaries=[], filename=None, two_cb=False):
    
    """Plot maximum loading of each line. 
    
    Parameters
    ----------
    network: PyPSA network container
        Holds topology of grid including results from powerflow analysis
    filename: str or None
        Save figure in this direction
    boundaries: array
       Set boundaries of heatmap axis
    two_cb: bool
        Choose if an extra colorbar for DC-lines is plotted
    
    """

    cmap_line = plt.cm.jet
    cmap_link = plt.cm.jet
    array_line = [['Line'] * len(network.lines), network.lines.index]
    array_link = [['Link'] * len(network.links), network.links.index]

    if network.lines_t.q0.empty:
        load_lines = pd.Series((abs(network.lines_t.p0).max(
                ) / (network.lines.s_nom) * 100).data, index=array_line)

    else: load_lines = pd.Series(((network.lines_t.p0**2 +
                           network.lines_t.q0 ** 2).max().apply(sqrt)/
                           (network.lines.s_nom) * 100).data, index=array_line)
        
    load_links = pd.Series((abs(network.links_t.p0.max(
                ) / (network.links.p_nom)) * 100).data, index=array_link)

    max_load = load_lines.append(load_links)

    ll = network.plot(
        line_colors=max_load,
        line_cmap={
            'Line': cmap_line,
            'Link': cmap_link},
        bus_sizes=0,
        title="Maximum of line loading",
        line_widths=2)

    if not boundaries:
        boundaries = [min(max_load), max(max_load)]

    v = np.linspace(boundaries[0], boundaries[1], 101)

    cb = plt.colorbar(ll[1], boundaries=v,
                      ticks=v[0:101:10])

    cb.set_clim(vmin=boundaries[0], vmax=boundaries[1])

    cb_Link = plt.colorbar(ll[2], boundaries=v,
                               ticks=v[0:101:10])
    cb_Link.set_clim(vmin=boundaries[0], vmax=boundaries[1])

    if two_cb:
        # cb_Link.set_label('Maximum load of DC-lines %')
        cb.set_label('Maximum load of AC-lines %')

    else:
        cb.set_label('Maximum load in %')
    if filename is None:
        plt.show()
    else:
        plt.savefig(filename)
        plt.close()