# help with a custom plot : chess board like table with colored cells

Hi Guys

I am starting to render plots with matplotlib as I learn both python and this interesting plotting library. I need help with a custom plot for a problem I am working on. May be there is an inbuilt function already.

Problem:
I am trying to draw a table(rectangle) as a plot with 96 individual cells ( 8 rows X 12 cols). Color each alternative cell with a specific color ( like a chess board : instead of black I will use some other color) and insert value for each cell from a pandas data frame or python dictionary. Show the col and row labels on the side.

Sample Data: http://pastebin.com/N4A7gWuH

Thanks!
-Abhi

I think you’ll need to use the function imshow with interpolation
set to None.

``````Sameer
``````
···

Actually, interpolation set to ‘none’, not the Python None. Here is some code:

a = np.zeros((8 * 12, 3))
a[::2, 0] = 1.0 # red
a[1::2, 2] = 0.75 # blue
a.shape = (8, 12, 3)

plt.imshow(a, interpolation=‘none’)
plt.show()

Note that there is currently a bug in plt.imsave() that makes saving this throw an exception (but you can still save using fig.savefig()).

Cheers!

Ben Root

···

On Tue, Apr 17, 2012 at 3:16 AM, Sameer Grover <sameer.grover.1@…287…> wrote:

On Tuesday 17 April 2012 12:36 PM, Abhishek Pratap wrote:

Hi Guys

``````  I am starting to render plots with matplotlib as I learn both
``````

python and this interesting plotting library. I need help with a
custom plot for a problem I am working on. May be there is an

``````  Problem:

I am trying to draw a table(rectangle) as a plot with 96
``````

individual cells ( 8 rows X 12 cols). Color each alternative cell
with a specific color ( like a chess board : instead of black I
will use some other color) and insert value for each cell from a
pandas data frame or python dictionary. Show the col and row
labels on the side.

``````  Sample Data:   [http://pastebin.com/N4A7gWuH](http://pastebin.com/N4A7gWuH)

Thanks!

-Abhi
``````
``````------------------------------------------------------------------------------
Better than sec? Nothing is better than sec when it comes to
monitoring Big Data applications. Try Boundary one-second resolution app monitoring today. Free.
[http://p.sf.net/sfu/Boundary-dev2dev](http://p.sf.net/sfu/Boundary-dev2dev)
``````
``````_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
[https://lists.sourceforge.net/lists/listinfo/matplotlib-users](https://lists.sourceforge.net/lists/listinfo/matplotlib-users)
``````
``````I think you'll need to use the function imshow with interpolation
``````

set to None.

``````Sameer
``````