def render_latex_mpl(text, path, color=(0, 0, 0), dpi=600, output='png'):
    """
    Render a LaTeX-formula into an image with matplotlib.

    Parameters
    ----------
    text : string
        String containing the latex-code.
    path : string
        Path to the file to be saved.
    color : tuple, optional
        color of the text given as rgb tuple. Default: ``(0, 0, 0)``
    dpi : int, optional
        Used dpi. Default: 1200
    output : string, optional
        Output format. Default: ``"png"``

    Notes
    -----
    If you get the following error:

        ``RuntimeError: libpng signaled error``

    Try to set the dpi higher. (1200 recomended)

    If big symbols like ``\\int`` or ``\\sum`` don't show up properly,
    try setting a

        ``\\displaystyle``

    infront of them.
    """
    from matplotlib.mathtext import MathTextParser
    from matplotlib.font_manager import FontProperties
    from matplotlib import figure, rc
    from matplotlib.backends import backend_agg
    rc('text', usetex=False)
    prop = FontProperties()
    parser = MathTextParser('path')
    width, height, depth, _, _ = parser.parse(text, dpi=72, prop=prop)
    fig = figure.Figure(figsize=(width / 72.0, height / 72.0))
    fig.text(0, depth / height, text, fontproperties=prop, color=color)
    backend_agg.FigureCanvasAgg(fig)
    fig.savefig(path, dpi=dpi, format=output, transparent=True)
