Title: Set The Color Of A Matplotlib Plot
Slug: set_the_color_of_a_matplotlib
Summary: Set The Color Of A Matplotlib Plot
Date: 2016-05-01 12:00
Category: Python
Tags: Data Visualization
Authors: Chris Albon

Import numpy and matplotlib.pyplot


In [1]:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt

Create some simulated data.


In [2]:
n = 100
r = 2 * np.random.rand(n)
theta = 2 * np.pi * np.random.rand(n)
area = 200 * r**2 * np.random.rand(n)
colors = theta

Create a scatterplot using the a colormap.

Full list of colormaps: http://wiki.scipy.org/Cookbook/Matplotlib/Show_colormaps


In [3]:
c = plt.scatter(theta, r, c=colors, s=area, cmap=plt.cm.RdYlGn)



In [4]:
c1 = plt.scatter(theta, r, c=colors, s=area, cmap=plt.cm.Blues)



In [5]:
c2 = plt.scatter(theta, r, c=colors, s=area, cmap=plt.cm.BrBG)



In [6]:
c3 = plt.scatter(theta, r, c=colors, s=area, cmap=plt.cm.Greens)



In [7]:
c4 = plt.scatter(theta, r, c=colors, s=area, cmap=plt.cm.RdGy)



In [8]:
c5 = plt.scatter(theta, r, c=colors, s=area, cmap=plt.cm.YlOrRd)



In [9]:
c6 = plt.scatter(theta, r, c=colors, s=area, cmap=plt.cm.autumn)



In [10]:
c7 = plt.scatter(theta, r, c=colors, s=area, cmap=plt.cm.binary)



In [11]:
c8 = plt.scatter(theta, r, c=colors, s=area, cmap=plt.cm.gist_earth)



In [12]:
c9 = plt.scatter(theta, r, c=colors, s=area, cmap=plt.cm.gist_heat)



In [13]:
c10 = plt.scatter(theta, r, c=colors, s=area, cmap=plt.cm.hot)



In [14]:
c11 = plt.scatter(theta, r, c=colors, s=area, cmap=plt.cm.spring)



In [15]:
c12 = plt.scatter(theta, r, c=colors, s=area, cmap=plt.cm.summer)



In [16]:
c12 = plt.scatter(theta, r, c=colors, s=area, cmap=plt.cm.winter)



In [17]:
c13 = plt.scatter(theta, r, c=colors, s=area, cmap=plt.cm.bone)



In [18]:
c14 = plt.scatter(theta, r, c=colors, s=area, cmap=plt.cm.cool)



In [19]:
c15 = plt.scatter(theta, r, c=colors, s=area, cmap=plt.cm.YlGn)



In [20]:
c16 = plt.scatter(theta, r, c=colors, s=area, cmap=plt.cm.RdBu)



In [21]:
c17 = plt.scatter(theta, r, c=colors, s=area, cmap=plt.cm.PuOr)



In [22]:
c18 = plt.scatter(theta, r, c=colors, s=area, cmap=plt.cm.Oranges)