def METHOD_NAME(fig, ax, x, y, z):
    points = np.array([x, y]).T.reshape(-1, 1, 2)
    segments = np.concatenate([points[:-1], points[1:]], axis=1)
    z = np.array(z)
    vmin = min(np.nanmin(z), np.nanmax(z) / 2)
    lc = LineCollection(
        segments,
        cmap=plt.get_cmap("plasma"),
        norm=matplotlib.colors.LogNorm(vmax=1, vmin=vmin),
    )
    lc.set_array(z)
    lc.set_linewidth(3)
    ax.add_collection(lc)
    fig.colorbar(lc, ax=ax)