Understanding `scale` in R

log simply takes the logarithm (base e, by default) of each element of the vector. scale, with default settings, will calculate the mean and standard deviation of the entire vector, then “scale” each element by those values by subtracting the mean and dividing by the sd. (If you use scale(x, scale=FALSE), it will only subtract … Read more

Changing the rotation of tick labels in Seaborn heatmap

seaborn uses matplotlib internally, as such you can use matplotlib functions to modify your plots. I’ve modified the code below to use the plt.yticks function to set rotation=0 which fixes the issue. import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns data = pd.DataFrame(np.random.normal(size=40*40).reshape(40,40)) yticks = data.index keptticks … 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

Make the size of a heatmap bigger with seaborn

You could alter the figsize by passing a tuple showing the width, height parameters you would like to keep. import matplotlib.pyplot as plt fig, ax = plt.subplots(figsize=(10,10)) # Sample figsize in inches sns.heatmap(df1.iloc[:, 1:6:], annot=True, linewidths=.5, ax=ax) EDIT I remember answering a similar question of yours where you had to set the index as TIMESTAMP. … Read more

Plotting a 2D heatmap

The imshow() function with parameters interpolation=’nearest’ and cmap=’hot’ should do what you want. Please review the interpolation parameter details, and see Interpolations for imshow and Image antialiasing. import matplotlib.pyplot as plt import numpy as np a = np.random.random((16, 16)) plt.imshow(a, cmap=’hot’, interpolation=’nearest’) plt.show()

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

Generate a heatmap 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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)