Draw a pretty plot from an array

    A function that performs all the tedious matplotlib
    magic to draw a 2D array with as few parameters and
    as little whitespace as possible.

    Parameters
    ----------
    array : array_like
        The input array to draw.
    filename : file, str or pathlib.Path
        The output image to save the array into.
    vmax : float, optional
        The default saturation threshold for the array. If set to None, the
        80th percentile value of the array is chosen. Default is None.
    dpi : int, optional
        Dots per inch (DPI) of the output image. Default is 200.

def spaceless_pdf_plot_maker(array, filename, vmax=None, dpi=DEFAULT_DPI):
    """Draw a pretty plot from an array

    A function that performs all the tedious matplotlib
    magic to draw a 2D array with as few parameters and
    as little whitespace as possible.

    Parameters
    ----------
    array : array_like
        The input array to draw.
    filename : file, str or pathlib.Path
        The output image to save the array into.
    vmax : float, optional
        The default saturation threshold for the array. If set to None, the
        80th percentile value of the array is chosen. Default is None.
    dpi : int, optional
        Dots per inch (DPI) of the output image. Default is 200.
    """

    if vmax is None:
        vmax = np.percentile(array, DEFAULT_SATURATION_THRESHOLD)
    plt.gca().set_axis_off()
    plt.subplots_adjust(top=1, bottom=0, right=1, left=0, hspace=0, wspace=0)
    plt.margins(0, 0)
    plt.gca().xaxis.set_major_locator(plt.NullLocator())
    plt.gca().yaxis.set_major_locator(plt.NullLocator())
    plt.figure()
    if SEABORN:
        sns.heatmap(array, vmax=vmax, cmap="Reds")
    else:
        plt.imshow(array, vmax=vmax, cmap="Reds", interpolation="none")
        plt.colorbar()
    plt.savefig(filename, bbox_inches="tight", pad_inches=0.0, dpi=dpi)
    plt.close()