heatmap

Change Seaborn heatmap Y-ticklabels font color for alternate labels

Change Seaborn heatmap Y-ticklabels font color for alternate labels Question: I have a seaborn heatmap with more than 100 labels on Y-axis. I want to change the font color of the Y-labels to red and blue in alternate way. If I have 10 Y-labels, then 5 labels should have the blue font & 5 labels …

Total answers: 2

Seaborn Heatmap – Display the heatmap only if values are above given threshold

Seaborn Heatmap – Display the heatmap only if values are above given threshold Question: The below python code displays sentence similarity, it uses Universal Sentence Encoder to achieve the same. from absl import logging import tensorflow as tf import tensorflow_hub as hub import matplotlib.pyplot as plt import numpy as np import os import pandas as …

Total answers: 2

seaborn.heatmap with varying cell sizes

seaborn.heatmap with varying cell sizes Question: I have a heatmap with ticks which have non equal deltas between themselves: For example, in the attached image, the deltas are between 0.015 to 0.13. The current scale doesn’t show the real scenario, since all cell sizes are equal. Is there a way to place the ticks in …

Total answers: 1

seaborn.heatmap in subplots with equal cell sizes

seaborn.heatmap in subplots with equal cell sizes Question: I am plotting various correlation matrices with a different number of columns using seaborn. For the sake of eye-candy, I’d like to have all correlation matrices to have the same cell size. Unfortunately, I am not able to parameterize seaborn to do so. Here is a minimal …

Total answers: 1

Insert line in heatmap after every 7th column

Insert line in heatmap after every 7th column Question: can someone help me how to add a veritcal line after every 7th column in my plot here? So I want to have after the new M1 starts a thick vertical line here.. Has someone an idea? My code is: piv = pd.pivot_table(df2, values="Corr",index=["GABA Receptor"], columns=["Experiment"], …

Total answers: 1

Separately adjust vertical and horizontal linewidth for seaborn.heatmap

Separately adjust vertical and horizontal linewidth for seaborn.heatmap Question: The parameter linewidth adjusts the size of the space between each cell. For example: import matplotlib.pyplot as plt import seaborn as sns; sns.set() import numpy as np; np.random.seed(0) uniform_data = np.random.rand(2000, 6) ax = sns.heatmap(uniform_data) plt.clf() ax = sns.heatmap(uniform_data, linewidth=0.0001) You can only see white, because …

Total answers: 1

Plot a Confusion Matrix in Python using a Dataframe of Strings

Plot a Confusion Matrix in Python using a Dataframe of Strings Question: I’m doing a 10-fold validation and I need to see how the accuracy of each class changes. I managed to create a DataFrame like this: Snippet: chars = [] for i in range(0, int(classes) + 1): row = [] for j in range(0, …

Total answers: 1

How to set center color in heatmap

How to set center color in heatmap Question: I want to plot a heatmap in seaborn. My code is following: plt.rcParams[‘font.size’] = 13 plt.rcParams[‘font.weight’] = ‘bold’ my_dpi=96 fig, ax = plt.subplots(figsize=(800/my_dpi, 600/my_dpi), dpi=my_dpi, facecolor=’black’) rdgn = sns.diverging_palette(h_neg=130, h_pos=10, s=99, l=55, sep=3) sns.heatmap(df, cmap=rdgn, center=0.00, annot=True, fmt =’.2%’, linewidths=1.3, linecolor=’black’, cbar=False, ax=ax) plt.savefig(‘./image/image.png’, dpi=96, facecolor=’black’) And …

Total answers: 2

How to set heatmap aspect ratio

How to set heatmap aspect ratio Question: I have a single-channel image where each integer pixel value maps to a string. For example 5 -> ‘person’. I’m trying to create an interactive image where hovering over a pixel will display it’s corresponding string. I figured using plotly heatmaps might be the way to do this. …

Total answers: 3

heatmap and dendrogram (clustermap) error using Plotly

heatmap and dendrogram (clustermap) error using Plotly Question: The last example in Plotly’s documentation for Dendrograms has an error. When executing this code, I get this error in two locations due to ‘extend’: AttributeError: ‘tuple’ object has no attribute ‘extend’ They are produced by these lines: figure.add_traces(heatmap) and figure[‘data’].extend(dendro_side[‘data’]) If anyone has run into this …

Total answers: 1