## Picasso's short lived blue period with Python

| categories: plotting | tags:

It is an unknown fact that Picasso had a brief blue plotting period with Matlab before moving on to his more famous paintings. It started from irritation with the default colors available in Matlab for plotting. After watching his friend van Gogh cut off his own ear out of frustration with the ugly default colors, Picasso had to do something different.

import numpy as np
import matplotlib.pyplot as plt

#this plots horizontal lines for each y value of m.
for m in np.linspace(1, 50, 100):
plt.plot([0, 50], [m, m])

plt.savefig('images/blues-1.png')

Picasso copied the table available at http://en.wikipedia.org/wiki/List_of_colors and parsed it into a dictionary of hex codes for new colors. That allowed him to specify a list of beautiful blues for his graph. Picasso eventually gave up on python as an artform, and moved on to painting.

import numpy as np
import matplotlib.pyplot as plt

c = {}
with open('color.table') as f:
for line in f:
fields = line.split('\t')
colorname = fields[0].lower()
hexcode = fields[1]
c[colorname] = hexcode

names = c.keys()
names = sorted(names)

print(names)

blues = [c['alice blue'],
c['light blue'],
c['baby blue'],
c['light sky blue'],
c['maya blue'],
c['cornflower blue'],
c['bleu de france'],
c['azure'],
c['blue sapphire'],
c['cobalt'],
c['blue'],
c['egyptian blue'],
c['duke blue']]

ax = plt.gca()
ax.set_color_cycle(blues)

#this plots horizontal lines for each y value of m.
for i, m in enumerate(np.linspace(1, 50, 100)):
plt.plot([0, 50], [m, m])

plt.savefig('images/blues-2.png')