Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matplotlib Color Palette

Tags:

matplotlib

Is it possible to change what colors Matplotlib cycles through when it is generating its own colors for a graph's lines? I'm using the pylab module.

from pylab import *
import matplotlib.cm as cm

x=[1,2,3,4]
y=[5,6,7,8]

fig1 = Figure()

plot1 = fig1.add_subplot(311)
plot1.plot(x,y)

plot2 = fig1.add_subplot(312)
plot2.plot(x,y)

plot3 = fig1.add_subplot(313)
plot3.plot(x,y)
like image 405
thenickname Avatar asked Dec 08 '10 15:12

thenickname


People also ask

What is matplotlib colormap?

Scientifically, the human brain perceives various intuition based on the different colors they see. Matplotlib provides some nice colormaps you can use, such as Sequential colormaps, Diverging colormaps, Cyclic colormaps, and Qualitative colormaps.

What is the default color in matplotlib?

MatPlotLib with Python The default color of a scatter point is blue. To get the default blue color of matplotlib scatter point, we can annotate them using annotate() method.


1 Answers

Yes, of course. Since it accept many kinds of color definition. It's easy to define your own color map. Here I just get colors from the colormap hot

import pylab as py
import numpy as np
import matplotlib.cm as cm
a = np.arange(0,10)

py.figure()
for i in np.arange(10):
    c = cm.hot(i/10.,1)
    py.plot(a,i*a,color=c)

py.show()

alt text

like image 155
gerry Avatar answered Oct 21 '22 21:10

gerry