Skip to content

Instantly share code, notes, and snippets.

@CnrLwlss
Last active February 18, 2016 16:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CnrLwlss/82da8b0cfcf9b962b031 to your computer and use it in GitHub Desktop.
Save CnrLwlss/82da8b0cfcf9b962b031 to your computer and use it in GitHub Desktop.
Continuous colour map in python with matplotlib. Requires matplotlib 1.5?
#http://matplotlib.org/examples/color/colormaps_reference.html
#http://matplotlib.org/users/colormaps.html
import matplotlib.pyplot as plt
from matplotlib import cm
import numpy as np
N = 200
x = np.random.randn(N)
y = np.random.randn(N)
colour = np.random.randn(N)
fig,ax=plt.subplots(2,2,figsize=(21,14))
ax[0,0].scatter(x, y, c=colour, cmap=cm.plasma,linewidth=0,s=100)
ax[0,0].set_axis_bgcolor('lightgrey')
ax[0,1].scatter(x, y, c=colour, cmap=cm.cool,linewidth=0,s=100)
ax[0,1].set_axis_bgcolor('lightgrey')
ax[1,0].scatter(x, y, c=colour, cmap=cm.coolwarm,linewidth=0,s=100)
ax[1,0].set_axis_bgcolor('white')
ax[1,1].scatter(x, y, c=colour, cmap=cm.Paired,linewidth=0,s=100)
ax[1,1].set_axis_bgcolor('lightgrey')
plt.show()
plt.scatter(x, y, c=colour, cmap=cm.plasma,linewidth=0,s=100)
plt.colorbar()
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment