Skip to content

Instantly share code, notes, and snippets.

@btel
Created January 28, 2013 16:55
Show Gist options
  • Save btel/4657162 to your computer and use it in GitHub Desktop.
Save btel/4657162 to your computer and use it in GitHub Desktop.
use custom colormaps with scatter and colorbra
#!/usr/bin/env python
#coding=utf-8
from matplotlib import cm
from matplotlib import colors
import numpy as np
import matplotlib.pyplot as plt
cm = colors.LinearSegmentedColormap.from_list(
"my_cmap", #nazwa (bez znaczenia)
['0.6', '0.3'], #min i max kolor ('0.3' to znaczy 30% szarosci)
N=10 # liczba poziomow
)
xy = np.arange(20)
sc = plt.scatter(xy, xy, c=xy, s=35, cmap=cm)
plt.colorbar(sc)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment