heatmap
Correlation among multiple categorical variables
You can using pd.factorize df.apply(lambda x : pd.factorize(x)[0]).corr(method=’pearson’, min_periods=1) Out[32]: a c d a 1.0 1.0 1.0 c 1.0 1.0 1.0 d 1.0 1.0 1.0 Data input df=pd.DataFrame({‘a’:[‘a’,’b’,’c’],’c’:[‘a’,’b’,’c’],’d’:[‘a’,’b’,’c’]}) Update from scipy.stats import chisquare df=df.apply(lambda x : pd.factorize(x)[0])+1 pd.DataFrame([chisquare(df[x].values,f_exp=df.values.T,axis=1)[0] for x in df]) Out[123]: 0 1 2 3 0 0.0 0.0 0.0 0.0 1 0.0 0.0 … Read more
Calculate RGB value for a range of values to create heat map
def rgb(minimum, maximum, value): minimum, maximum = float(minimum), float(maximum) ratio = 2 * (value-minimum) / (maximum – minimum) b = int(max(0, 255*(1 – ratio))) r = int(max(0, 255*(ratio – 1))) g = 255 – b – r return r, g, b
Custom Annotation Seaborn Heatmap
This feature has just been added in the recent version of Seaborn 0.7.1. From Seaborn update history: The annot parameter of heatmap() now accepts a rectangular dataset in addition to a boolean value. If a dataset is passed, its values will be used for the annotations, while the main dataset will be used for the … Read more
How to recalculate x,y coordinates based on screensize
Have you tried this mathematical formula to change the range of a number? And also instead of storing this: x, y, width, height 433, 343, 1257, 959 331, 823, 1257, 959 You could store it normalized between 0 and 1 so it works for any width/height (calculated by dividing each x by its width and … Read more