Skip to main content

Posts

Showing posts from April, 2014

Matplotlib Colormap

Matplotlib Colormap This a small tutorial for making custom color map for matplotlib . You can also check the documentary page here .  One simple way to make  the colormap is using the available colours.  Here is a simple example .   import matplotlib.pyplot as plt from matplotlib import colors import numpy as np zvals = np.random.rand(10, 10) #cmap=colors.LinearSegmentedColormap.from_list("mycolor",['white', 'red','green','black']) cmap=colors.LinearSegmentedColormap.from_list("mycolor",['white','black']) img = plt.imshow(zvals, interpolation='nearest', origin='lower',cmap=cmap)                  

Matplotlib 2D plot colors

  Colors in matplotlib In this tutorial I will talk about colors in matplotlib. For more info check the Matplotlib color documentary . Basic color which are available in the matplotlib is         b: blue         g: green         r: red         c: cyan         m: magenta         y: yellow         k: black         w: white Somthing simple like this.   import pylab as pl x=pl.arange(10) pl.plot(x*x,"-*",color="r",markersize=30)       You can also specify any name as use in the html( like "IndianRed" ) . See   This page. pl.plot(x*x,"-*",color="IndianRed",markersize=30) you can pass an R , G , B tuple, where each of R , G , B are in the range [0,1...