No color map | There is a color map |
---|---|
If you are dealing with continuous data, you can create beautiful graphs by using color maps.
The color map is obtained with plt.get_cmap ()
. By passing a numerical value (0.0 to 1.0) to the acquired color map, you can use the colors in that color map.
demo.py
import numpy as np
import matplotlib.pyplot as plt
N = 16
x = np.arange(0, 4, 0.01)
y = [i * np.sin(x)**2 for i in xrange(N)]
cmap = plt.get_cmap("Blues")
for i in xrange(len(y)):
plt.plot(x, y[i], c=cmap(float(i)/N))
plt.show()
Reds | Greens | Blues | binary |
---|---|---|---|
spring | summer | autumn | winter |
---|---|---|---|
Click here for other colormaps (http://matplotlib.org/examples/color/colormaps_reference.html)
matplotlib: Automatically color coded --Qiita http://qiita.com/konnyakmannan/items/ab297d53afd9dc94e0e8
color example code: colormaps_reference.py — Matplotlib 1.5.3 documentation http://matplotlib.org/examples/color/colormaps_reference.html
Displaying and setting the current colormap - MATLAB colormap --MathWorks Japan http://jp.mathworks.com/help/matlab/ref/colormap.html
Recommended Posts