def gnuplot_3d_matrix(z_matrix, filename, title='', x_label='', y_label=''):
    '''
    Function to produce a general 3D plot from a 2D matrix.

    Args:
        z_matrix (list): 2D matrix.
        filename (str): Filename of the output image.
        title (str): Title of the plot.  Default is '' (no title).
        x_label (str): x-axis label.
        y_label (str): y-axis label.
    '''
    _, ext = os.path.splitext(filename)
    if ext != '.png':
        filename += '.png'

    gnuplot_cmds = \
    '''
    set datafile separator ","
    set term pngcairo size 30cm,25cm
    set out filename

    unset key
    set border lw 1.5
    set view map

    set title title
    set xlabel x_label
    set ylabel y_label

    splot filename_data matrix w pm3d
    '''
    scr = _GnuplotScriptTemp(gnuplot_cmds)
    data = _GnuplotDataZMatrixTemp(z_matrix)

    args_dict = {
        'filename': filename,
        'filename_data': data.name,
        'title': title,
        'x_label': x_label,
        'y_label': y_label
    }
    gnuplot(scr.name, args_dict)