pymks/tools.py
def _draw_fields(fields, field_cmap, fontsize, titles):
    """
    Helper function used to draw fields.

    Args:
        fields - iterable object with 2D numpy arrays
        field_cmap - color map for plot
        fontsize - font size for titles and color bar text
        titles - titles for plot
    """
    plt.close('all')
    vmin = np.min(fields)
    vmax = np.max(fields)
    n_fields = len(fields)
    if titles is not None:
        n_titles = len(titles)
        if n_fields != n_titles:
            raise RuntimeError(
                "number of plots does not match number of labels.")
    plt.close('all')
    fig, axs = plt.subplots(1, n_fields, figsize=(n_fields * 4, 4))
    if n_fields > 1:
        for field, ax, title in zip(fields, axs.flat, titles):
            im = ax.imshow(field.swapaxes(0, 1),
                           cmap=field_cmap, interpolation='none',
                           vmin=vmin, vmax=vmax)
            ax.set_xticks(())
            ax.set_yticks(())
            ax.set_title(title, fontsize=fontsize)
    else:
        im = axs.imshow(fields[0].swapaxes(0, 1), cmap=field_cmap,
                        interpolation='none', vmin=vmin, vmax=vmax)
        axs.set_xticks(())
        axs.set_yticks(())
        axs.set_title(titles[0], fontsize=fontsize)
    fig.subplots_adjust(right=0.8)
    cbar_ax = fig.add_axes([1.0, 0.05, 0.05, 0.9])
    cbar_font = np.floor(0.8 * fontsize)
    cbar_ax.tick_params(labelsize=cbar_font)
    cbar_ax.yaxis.set_offset_position('right')
    fig.colorbar(im, cax=cbar_ax)
    plt.tight_layout()
    plt.rc('font', **{'size': str(cbar_font)})
    plt.show()

    Helper function used to draw fields.

    Args:
        fields - iterable object with 2D numpy arrays
        field_cmap - color map for plot
        fontsize - font size for titles and color bar text
        titles - titles for plot
    
Helper function used to draw fields.
Args:
fields - iterable object with 2D numpy arrays
field_cmap - color map for plot
fontsize - font size for titles and color bar text
titles - titles for plot
Helper function used to draw fields . Args : fields - iterable object with 2D numpy arrays field_cmap - color map for plot fontsize - font size for titles and color bar text titles - titles for plot
def _draw_fields(fields, field_cmap, fontsize, titles):
    plt.close('all')
    vmin = np.min(fields)
    vmax = np.max(fields)
    n_fields = len(fields)
    if titles is not None:
        n_titles = len(titles)
        if n_fields != n_titles:
            raise RuntimeError(
                "number of plots does not match number of labels.")
    plt.close('all')
    fig, axs = plt.subplots(1, n_fields, figsize=(n_fields * 4, 4))
    if n_fields > 1:
        for field, ax, title in zip(fields, axs.flat, titles):
            im = ax.imshow(field.swapaxes(0, 1),
                           cmap=field_cmap, interpolation='none',
                           vmin=vmin, vmax=vmax)
            ax.set_xticks(())
            ax.set_yticks(())
            ax.set_title(title, fontsize=fontsize)
    else:
        im = axs.imshow(fields[0].swapaxes(0, 1), cmap=field_cmap,
                        interpolation='none', vmin=vmin, vmax=vmax)
        axs.set_xticks(())
        axs.set_yticks(())
        axs.set_title(titles[0], fontsize=fontsize)
    fig.subplots_adjust(right=0.8)
    cbar_ax = fig.add_axes([1.0, 0.05, 0.05, 0.9])
    cbar_font = np.floor(0.8 * fontsize)
    cbar_ax.tick_params(labelsize=cbar_font)
    cbar_ax.yaxis.set_offset_position('right')
    fig.colorbar(im, cax=cbar_ax)
    plt.tight_layout()
    plt.rc('font', **{'size': str(cbar_font)})
    plt.show()
def _draw_fields ( fields , field_cmap , fontsize , titles ) : plt . close ( 'all' ) vmin = np . min ( fields ) vmax = np . max ( fields ) n_fields = len ( fields ) if titles is not None : n_titles = len ( titles ) if n_fields != n_titles : raise RuntimeError ( "number of plots does not match number of labels." ) plt . close ( 'all' ) fig , axs = plt . subplots ( 1 , n_fields , figsize = ( n_fields * 4 , 4 ) ) if n_fields > 1 : for field , ax , title in zip ( fields , axs . flat , titles ) : im = ax . imshow ( field . swapaxes ( 0 , 1 ) , cmap = field_cmap , interpolation = 'none' , vmin = vmin , vmax = vmax ) ax . set_xticks ( ( ) ) ax . set_yticks ( ( ) ) ax . set_title ( title , fontsize = fontsize ) else : im = axs . imshow ( fields [ 0 ] . swapaxes ( 0 , 1 ) , cmap = field_cmap , interpolation = 'none' , vmin = vmin , vmax = vmax ) axs . set_xticks ( ( ) ) axs . set_yticks ( ( ) ) axs . set_title ( titles [ 0 ] , fontsize = fontsize ) fig . subplots_adjust ( right = 0.8 ) cbar_ax = fig . add_axes ( [ 1.0 , 0.05 , 0.05 , 0.9 ] ) cbar_font = np . floor ( 0.8 * fontsize ) cbar_ax . tick_params ( labelsize = cbar_font ) cbar_ax . yaxis . set_offset_position ( 'right' ) fig . colorbar ( im , cax = cbar_ax ) plt . tight_layout ( ) plt . rc ( 'font' , ** { 'size' : str ( cbar_font ) } ) plt . show ( )
Helper function used to draw fields.
Helper function used to draw fields .
"""
    Helper function used to draw fields.

    Args:
        fields - iterable object with 2D numpy arrays
        field_cmap - color map for plot
        fontsize - font size for titles and color bar text
        titles - titles for plot
    """
fields
field_cmap
fontsize
titles