creating colors for many plots

i have found a solution for creating colors for many plots at this page:
http://stackoverflow.com/questions/7513262/matplotlib-large-set-of-colors-for-plots

what does this the following line do?
colors = plt.get_cmap('jet')(np.linspace(0, 1.0, len(kinds)))

plt.get_cmap('jet') gets a LinearSegmentedColormap object and np.linspace
creates a ndarray
but what happens because of this instruction?

···

--
View this message in context: http://matplotlib.1069221.n5.nabble.com/creating-colors-for-many-plots-tp43381.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

A colormap can be called like a function to get the colors associated to (normalized) values. In your example, it is called with uniformly spaced values (linspace) between 0 and 1. This should return the corresponding colors.

print plt.get_cmap('gray')(0.0)
(0.0, 0.0, 0.0, 1.0)

print plt.get_cmap('gray')(1.0)
(1.0, 1.0, 1.0, 1.0)

print plt.get_cmap('gray')(np.linspace(0,1,6))
[[ 0. 0. 0. 1. ]
[ 0.2 0.2 0.2 1. ]
[ 0.4 0.4 0.4 1. ]
[ 0.6 0.6 0.6 1. ]
[ 0.8 0.8 0.8 1. ]
[ 1. 1. 1. 1. ]]

Nicolas

···

On 08 May 2014, at 11:41, MaxMax <a3233277@...4530...> wrote:

i have found a solution for creating colors for many plots at this page:
python - matplotlib large set of colors for plots - Stack Overflow

what does this the following line do?
colors = plt.get_cmap('jet')(np.linspace(0, 1.0, len(kinds)))

plt.get_cmap('jet') gets a LinearSegmentedColormap object and np.linspace
creates a ndarray
but what happens because of this instruction?

--
View this message in context: http://matplotlib.1069221.n5.nabble.com/creating-colors-for-many-plots-tp43381.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Is your legacy SCM system holding you back? Join Perforce May 7 to find out:
&#149; 3 signs your SCM is hindering your productivity
&#149; Requirements for releasing software faster
&#149; Expert tips and advice for migrating your SCM now
http://p.sf.net/sfu/perforce
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

thanks

I found the spectral colormap is best suited to distinguish between many
equal spaced colors.

I am find it sad, that matplotlib has so many features, but is so
unintuitive to use.

···

--
View this message in context: http://matplotlib.1069221.n5.nabble.com/creating-colors-for-many-plots-tp43381p43383.html
Sent from the matplotlib - users mailing list archive at Nabble.com.