Making heatmap from pandas DataFrame

For people looking at this today, I would recommend the Seaborn heatmap() as documented here. The example above would be done as follows: import numpy as np from pandas import DataFrame import seaborn as sns %matplotlib inline Index= [‘aaa’, ‘bbb’, ‘ccc’, ‘ddd’, ‘eee’] Cols = [‘A’, ‘B’, ‘C’, ‘D’] df = DataFrame(abs(np.random.randn(5, 4)), index=Index, columns=Cols) … Read more

Heatmap in matplotlib with pcolor?

This is late, but here is my python implementation of the flowingdata NBA heatmap. updated:1/4/2014: thanks everyone # -*- coding: utf-8 -*- # <nbformat>3.0</nbformat> # ———————————————————————— # Filename : heatmap.py # Date : 2013-04-19 # Updated : 2014-01-04 # Author : @LotzJoe >> Joe Lotz # Description: My attempt at reproducing the FlowingData graphic in … Read more

Generate a heatmap in MatPlotLib using a scatter data set

If you don’t want hexagons, you can use numpy’s histogram2d function: import numpy as np import numpy.random import matplotlib.pyplot as plt # Generate some test data x = np.random.randn(8873) y = np.random.randn(8873) heatmap, xedges, yedges = np.histogram2d(x, y, bins=50) extent = [xedges[0], xedges[-1], yedges[0], yedges[-1]] plt.clf() plt.imshow(heatmap.T, extent=extent, origin=’lower’) plt.show() This makes a 50×50 heatmap. … Read more