Good morning everyone,
I'd like tu represent a heatmap with its color bar in log scale. For that pourpose, I used LogNorm function but the scale bar only shows 2 values(picture attached 1). How could I modify this bar, maybe its limits, to make it appear as a "normal" color bar (pic attached 2).
here the code:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from matplotlib.colors import LogNorm
df = pd.read_excel(r'X.xlsx',
)
df0 = pd.DataFrame(np.full((14, 23), np.nan))
n=7
m = 0
for i in df0:
while n < 10:
df0.loc[10, n] = df['mechanic threshold N'][m]
n = n + 1
m = m + 1
df0.loc[11, 8] = df['mechanic threshold N'][3]
n= 7+5
m = 0
for i in df0:
while n < 10+5:
df0.loc[10, n] = df['mechanic threshold Y'][m]
n = n + 1
m = m + 1
df0.loc[11, 8+5] = df['mechanic threshold Y'][3]
sns.heatmap(df0,
cmap="mako", norm=LogNorm()).set(title='X', xticklabels=[], yticklabels=[],
)
plt.tick_params(axis='both', which='both', length=0)
plt.show()
here the pics:
1.heatmap with the bad color bar 2. heatmap with a color bar as I would like it to appear. I know that the logarithmic scale is different, but leave it more like this and not just that 2 values appear as in the previous image
here part of the data frame:
point | mechanic threshold N | mechanic threshold Y |
---|---|---|
1 | 0.047857143 | 0.064 |
2 | 0.051 | 0.058 |
3 | 0.046470588 | 0.037058824 |
4 | 0.097142857 | 0.082 |
Thank you all very much in advance, greetings!
I tried vmin and vmax method but it didn't work