In [1]:
%matplotlib inline

In [2]:
import matplotlib.pyplot as plt
import numpy as np
import csv, json
plt.rcParams["figure.figsize"] = (12,12)

In [3]:
ega_palette = {
    0:  (0x00, 0x00, 0x00),
    1:  (0x00, 0x00, 0xAA),
    2:  (0x00, 0xAA, 0x00),
    3:  (0x00, 0xAA, 0xAA),
    4:  (0xAA, 0x00, 0x00),
    5:  (0xAA, 0x00, 0xAA),
    6:  (0xAA, 0x55, 0x00),
    7:  (0xAA, 0xAA, 0xAA),
    8:  (0x55, 0x55, 0x55),
    9:  (0x55, 0x55, 0xFF),
    10: (0x55, 0xFF, 0x55),
    11: (0x55, 0xFF, 0xFF),
    12: (0xFF, 0x55, 0x55),
    13: (0xFF, 0x55, 0xFF),
    14: (0xFF, 0xFF, 0x55),
    15: (0xFF, 0xFF, 0xFF),
}

In [4]:
im = np.zeros((16, 4), dtype="uint8")
im[:,3] = 255
for i in ega_palette:
    im[i,:3] = ega_palette[i]
im2 = im.reshape((4,4,4))

In [5]:
plt.imshow(im2, interpolation="nearest")


Out[5]:
<matplotlib.image.AxesImage at 0x7fd2e8dc5748>

In [6]:
plt.style.available


Out[6]:
['seaborn-dark-palette',
 'seaborn-deep',
 'seaborn-poster',
 'seaborn-colorblind',
 'seaborn-white',
 'seaborn-talk',
 'classic',
 'fivethirtyeight',
 'seaborn-paper',
 'seaborn-muted',
 'seaborn-notebook',
 'seaborn-pastel',
 'seaborn-ticks',
 'dark_background',
 'seaborn-bright',
 'ggplot',
 '_classic_test',
 'grayscale',
 'seaborn',
 'seaborn-darkgrid',
 'seaborn-whitegrid',
 'seaborn-dark',
 'bmh']

In [7]:
import ipywidgets
import numpy as np

def make_cardiod(a = 0.5, style="classic"):
    theta = np.mgrid[0.0:2.0*np.pi:1000j]
    r = a**3 * np.sin(theta-2)**2 + 4 * np.cos(2*theta-5)
    with plt.style.context(style):
        plt.polar(r, theta,)

In [8]:
ipywidgets.interact(make_cardiod, a = (0.0, 10.0, 0.01), style = sorted(plt.style.available))


Out[8]:
<function __main__.make_cardiod>

In [9]:
colors = ["#{0:02x}{1:02x}{2:02x}".format(*_) for _ in im.tolist()]
colors


Out[9]:
['#000000',
 '#0000aa',
 '#00aa00',
 '#00aaaa',
 '#aa0000',
 '#aa00aa',
 '#aa5500',
 '#aaaaaa',
 '#555555',
 '#5555ff',
 '#55ff55',
 '#55ffff',
 '#ff5555',
 '#ff55ff',
 '#ffff55',
 '#ffffff']

In [10]:
cycle = plt.cycler("colors", colors)

In [11]:
plt.scatter([1,2,3,4], [2,3,4,5])
plt.scatter([1,2,3,4], [1,2,3,4])
plt.scatter([1,2,3,4], [3,4,5,6])


Out[11]:
<matplotlib.collections.PathCollection at 0x7fd2e8c86a58>

In [12]:
with plt.style.context("seaborn"):
    plt.scatter([1,2,3,4], [2,3,4,5])
    plt.scatter([1,2,3,4], [1,2,3,4])
    plt.scatter([1,2,3,4], [3,4,5,6])



In [13]:
plt.scatter([1,2,3,4], [2,3,4,5])
plt.scatter([1,2,3,4], [1,2,3,4])
plt.scatter([1,2,3,4], [3,4,5,6])


Out[13]:
<matplotlib.collections.PathCollection at 0x7fd2e8b47e48>

In [14]:
print(colors)


['#000000', '#0000aa', '#00aa00', '#00aaaa', '#aa0000', '#aa00aa', '#aa5500', '#aaaaaa', '#555555', '#5555ff', '#55ff55', '#55ffff', '#ff5555', '#ff55ff', '#ffff55', '#ffffff']

In [15]:
plt.rcParams.keys()


Out[15]:
['_internal.classic_mode',
 'agg.path.chunksize',
 'animation.avconv_args',
 'animation.avconv_path',
 'animation.bitrate',
 'animation.codec',
 'animation.convert_args',
 'animation.convert_path',
 'animation.ffmpeg_args',
 'animation.ffmpeg_path',
 'animation.frame_format',
 'animation.html',
 'animation.mencoder_args',
 'animation.mencoder_path',
 'animation.writer',
 'axes.autolimit_mode',
 'axes.axisbelow',
 'axes.edgecolor',
 'axes.facecolor',
 'axes.formatter.limits',
 'axes.formatter.offset_threshold',
 'axes.formatter.use_locale',
 'axes.formatter.use_mathtext',
 'axes.formatter.useoffset',
 'axes.grid',
 'axes.grid.axis',
 'axes.grid.which',
 'axes.hold',
 'axes.labelcolor',
 'axes.labelpad',
 'axes.labelsize',
 'axes.labelweight',
 'axes.linewidth',
 'axes.prop_cycle',
 'axes.spines.bottom',
 'axes.spines.left',
 'axes.spines.right',
 'axes.spines.top',
 'axes.titlepad',
 'axes.titlesize',
 'axes.titleweight',
 'axes.unicode_minus',
 'axes.xmargin',
 'axes.ymargin',
 'axes3d.grid',
 'backend',
 'backend.qt4',
 'backend.qt5',
 'backend_fallback',
 'boxplot.bootstrap',
 'boxplot.boxprops.color',
 'boxplot.boxprops.linestyle',
 'boxplot.boxprops.linewidth',
 'boxplot.capprops.color',
 'boxplot.capprops.linestyle',
 'boxplot.capprops.linewidth',
 'boxplot.flierprops.color',
 'boxplot.flierprops.linestyle',
 'boxplot.flierprops.linewidth',
 'boxplot.flierprops.marker',
 'boxplot.flierprops.markeredgecolor',
 'boxplot.flierprops.markerfacecolor',
 'boxplot.flierprops.markersize',
 'boxplot.meanline',
 'boxplot.meanprops.color',
 'boxplot.meanprops.linestyle',
 'boxplot.meanprops.linewidth',
 'boxplot.meanprops.marker',
 'boxplot.meanprops.markeredgecolor',
 'boxplot.meanprops.markerfacecolor',
 'boxplot.meanprops.markersize',
 'boxplot.medianprops.color',
 'boxplot.medianprops.linestyle',
 'boxplot.medianprops.linewidth',
 'boxplot.notch',
 'boxplot.patchartist',
 'boxplot.showbox',
 'boxplot.showcaps',
 'boxplot.showfliers',
 'boxplot.showmeans',
 'boxplot.vertical',
 'boxplot.whiskerprops.color',
 'boxplot.whiskerprops.linestyle',
 'boxplot.whiskerprops.linewidth',
 'boxplot.whiskers',
 'contour.corner_mask',
 'contour.negative_linestyle',
 'datapath',
 'date.autoformatter.day',
 'date.autoformatter.hour',
 'date.autoformatter.microsecond',
 'date.autoformatter.minute',
 'date.autoformatter.month',
 'date.autoformatter.second',
 'date.autoformatter.year',
 'docstring.hardcopy',
 'errorbar.capsize',
 'examples.directory',
 'figure.autolayout',
 'figure.dpi',
 'figure.edgecolor',
 'figure.facecolor',
 'figure.figsize',
 'figure.frameon',
 'figure.max_open_warning',
 'figure.subplot.bottom',
 'figure.subplot.hspace',
 'figure.subplot.left',
 'figure.subplot.right',
 'figure.subplot.top',
 'figure.subplot.wspace',
 'figure.titlesize',
 'figure.titleweight',
 'font.cursive',
 'font.family',
 'font.fantasy',
 'font.monospace',
 'font.sans-serif',
 'font.serif',
 'font.size',
 'font.stretch',
 'font.style',
 'font.variant',
 'font.weight',
 'grid.alpha',
 'grid.color',
 'grid.linestyle',
 'grid.linewidth',
 'hatch.color',
 'hatch.linewidth',
 'hist.bins',
 'image.aspect',
 'image.cmap',
 'image.composite_image',
 'image.interpolation',
 'image.lut',
 'image.origin',
 'image.resample',
 'interactive',
 'keymap.all_axes',
 'keymap.back',
 'keymap.forward',
 'keymap.fullscreen',
 'keymap.grid',
 'keymap.home',
 'keymap.pan',
 'keymap.quit',
 'keymap.save',
 'keymap.xscale',
 'keymap.yscale',
 'keymap.zoom',
 'legend.borderaxespad',
 'legend.borderpad',
 'legend.columnspacing',
 'legend.edgecolor',
 'legend.facecolor',
 'legend.fancybox',
 'legend.fontsize',
 'legend.framealpha',
 'legend.frameon',
 'legend.handleheight',
 'legend.handlelength',
 'legend.handletextpad',
 'legend.labelspacing',
 'legend.loc',
 'legend.markerscale',
 'legend.numpoints',
 'legend.scatterpoints',
 'legend.shadow',
 'lines.antialiased',
 'lines.color',
 'lines.dash_capstyle',
 'lines.dash_joinstyle',
 'lines.dashdot_pattern',
 'lines.dashed_pattern',
 'lines.dotted_pattern',
 'lines.linestyle',
 'lines.linewidth',
 'lines.marker',
 'lines.markeredgewidth',
 'lines.markersize',
 'lines.scale_dashes',
 'lines.solid_capstyle',
 'lines.solid_joinstyle',
 'markers.fillstyle',
 'mathtext.bf',
 'mathtext.cal',
 'mathtext.default',
 'mathtext.fallback_to_cm',
 'mathtext.fontset',
 'mathtext.it',
 'mathtext.rm',
 'mathtext.sf',
 'mathtext.tt',
 'nbagg.transparent',
 'patch.antialiased',
 'patch.edgecolor',
 'patch.facecolor',
 'patch.force_edgecolor',
 'patch.linewidth',
 'path.effects',
 'path.simplify',
 'path.simplify_threshold',
 'path.sketch',
 'path.snap',
 'pdf.compression',
 'pdf.fonttype',
 'pdf.inheritcolor',
 'pdf.use14corefonts',
 'pgf.debug',
 'pgf.preamble',
 'pgf.rcfonts',
 'pgf.texsystem',
 'plugins.directory',
 'polaraxes.grid',
 'ps.distiller.res',
 'ps.fonttype',
 'ps.papersize',
 'ps.useafm',
 'ps.usedistiller',
 'savefig.bbox',
 'savefig.directory',
 'savefig.dpi',
 'savefig.edgecolor',
 'savefig.facecolor',
 'savefig.format',
 'savefig.frameon',
 'savefig.jpeg_quality',
 'savefig.orientation',
 'savefig.pad_inches',
 'savefig.transparent',
 'scatter.marker',
 'svg.fonttype',
 'svg.hashsalt',
 'svg.image_inline',
 'text.antialiased',
 'text.color',
 'text.dvipnghack',
 'text.hinting',
 'text.hinting_factor',
 'text.latex.preamble',
 'text.latex.preview',
 'text.latex.unicode',
 'text.usetex',
 'timezone',
 'tk.window_focus',
 'toolbar',
 'verbose.fileo',
 'verbose.level',
 'webagg.open_in_browser',
 'webagg.port',
 'webagg.port_retries',
 'xtick.alignment',
 'xtick.bottom',
 'xtick.color',
 'xtick.direction',
 'xtick.labelsize',
 'xtick.major.bottom',
 'xtick.major.pad',
 'xtick.major.size',
 'xtick.major.top',
 'xtick.major.width',
 'xtick.minor.bottom',
 'xtick.minor.pad',
 'xtick.minor.size',
 'xtick.minor.top',
 'xtick.minor.visible',
 'xtick.minor.width',
 'xtick.top',
 'ytick.alignment',
 'ytick.color',
 'ytick.direction',
 'ytick.labelsize',
 'ytick.left',
 'ytick.major.left',
 'ytick.major.pad',
 'ytick.major.right',
 'ytick.major.size',
 'ytick.major.width',
 'ytick.minor.left',
 'ytick.minor.pad',
 'ytick.minor.right',
 'ytick.minor.size',
 'ytick.minor.visible',
 'ytick.minor.width',
 'ytick.right']

In [16]:
with plt.style.context({'axes.prop_cycle': plt.cycler('color', colors),
                       'xtick.labelsize': 20, 'figure.facecolor': "#AAAAAA"}):
    plt.plot([1,2,3,4], [2,3,4,5])
    plt.plot([1,2,3,4], [1,2,3,4])
    plt.plot([1,2,3,4], [3,4,5,6])



In [17]:
with plt.style.context(["seaborn", 
                       {'axes.prop_cycle': plt.cycler('color', colors),
                       'xtick.labelsize': 20}]):
    plt.plot([1,2,3,4], [2,3,4,5])
    plt.plot([1,2,3,4], [1,2,3,4])
    plt.plot([1,2,3,4], [3,4,5,6])



In [ ]: