heatmap
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
How to understand Seaborn’s heatmap annotation format
There isn’t a clear and quick answer to this at the top of search engine results so I provide simple examples here: .1e = scientific notation with 1 decimal point (standard form) .2f = 2 decimal places .3g = 3 significant figures .4% = percentage with 4 decimal places A more detailed explanation on the … Read more
Is there any way to use bivariate colormaps in matplotlib?
imshow can take an array of [r, g, b] entries. So you can convert the absolute values to intensities and phases – to hues. I will use as an example complex numbers, because for it it makes the most sense. If needed, you can always add numpy arrays Z = X + 1j * Y. … Read more
First and last row cut in half of heatmap plot
Unfortunately matplotlib 3.1.1 broke seaborn heatmaps; and in general inverted axes with fixed ticks. This is fixed in the current development version; you may hence revert to matplotlib 3.1.0 use matplotlib 3.1.2 or higher set the heatmap limits manually (ax.set_ylim(bottom, top) # set the ylim to bottom, top)
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
Seaborn showing scientific notation in heatmap for 3-digit numbers
According to the docs, the param fmt=”.2g” is being applied because you’ve set annot=True so you can modify the format being applied to: sns.heatmap(table2,annot=True,cmap=’Blues’, fmt=”g”)