def visualize_dim_red(r, labels, filename=None, figsize=(<NUM_LIT>,<NUM_LIT:10>), title='<STR_LIT>', legend=True, label_map=None, label_scale=False, label_color_map=None, **scatter_options):
fig = plt.figure(figsize=figsize)<EOL>plt.cla()<EOL>if not label_scale:<EOL><INDENT>for i in set(labels):<EOL><INDENT>label = i<EOL>if label_map is not None:<EOL><INDENT>label = label_map[i]<EOL><DEDENT>if label_color_map is not None:<EOL><INDENT>c = label_color_map[i]<EOL>plt.scatter(r[<NUM_LIT:0>, labels==i], r[<NUM_LIT:1>, labels==i], label=label, c=c, **scatter_options)<EOL><DEDENT>else:<EOL><INDENT>plt.scatter(r[<NUM_LIT:0>, labels==i], r[<NUM_LIT:1>, labels==i], label=label, **scatter_options)<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>if labels is None:<EOL><INDENT>plt.scatter(r[<NUM_LIT:0>,:], r[<NUM_LIT:1>,:], **scatter_options)<EOL><DEDENT>else:<EOL><INDENT>plt.scatter(r[<NUM_LIT:0>,:], r[<NUM_LIT:1>,:], c=labels/labels.max(), **scatter_options)<EOL><DEDENT><DEDENT>plt.title(title)<EOL>if legend:<EOL><INDENT>plt.legend()<EOL><DEDENT>if filename is not None:<EOL><INDENT>plt.savefig(filename, dpi=<NUM_LIT:100>)<EOL>plt.close()<EOL><DEDENT>return fig<EOL>
Saves a scatter plot of a (2,n) matrix r, where each column is a cell.

Args:
    r (array): (2,n) matrix
    labels (array): (n,) array of ints/strings or floats. Can be None.
    filename (string): string to save the output graph. If None, then this just displays the plot.
    figsize (tuple): Default: (18, 10)
    title (string): graph title
    legend (bool): Default: True
    label_map (dict): map of labels to label names. Default: None
    label_scale (bool): True if labels is should be treated as floats. Default: False
    label_color_map (array): (n,) array or list of colors for each label.