Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ValueError: left cannot be >= right on sns.heatmap

I have this value of m:

array([[0.91992515, 0.978894  , 0.98183531, 0.99085009, 0.98576438,
        0.99062014, 0.9931621 , 0.99088091, 0.92711413, 0.78091824],
       [0.92729372, 0.97037023, 0.98044407, 0.97998279, 0.97441202,
        0.99145925, 0.98606282, 0.99012506, 0.94134074, 0.79332185],
       [0.92185014, 0.95902878, 0.97929859, 0.98272425, 0.98107767,
        0.98998082, 0.99233872, 0.9882673 , 0.92030007, 0.80480009],
       [0.91204637, 0.96461374, 0.97577399, 0.98063707, 0.96949238,
        0.99135023, 0.98836327, 0.98504972, 0.97783262, 0.77362221],
       [0.93386984, 0.97553176, 0.97664225, 0.98727471, 0.98023629,
        0.98472446, 0.98551005, 0.98410082, 0.9551242 , 0.77246934],
       [0.93045634, 0.97707605, 0.99085528, 0.98433924, 0.98237419,
        0.99572343, 0.99173379, 0.98824054, 0.96632308, 0.76564348],
       [0.93682766, 0.97289765, 0.98349541, 0.99275345, 0.98538131,
        0.99283469, 0.99232531, 0.98699528, 0.95912874, 0.91011888],
       [0.89040715, 0.96955484, 0.97332346, 0.96521449, 0.97545224,
        0.98275667, 0.98541254, 0.97983998, 0.90709436, 0.88003486],
       [0.95064926, 0.9512195 , 0.96981376, 0.9641239 , 0.98085016,
        0.95860326, 0.9453789 , 0.89857048, 0.94533682, 0.67875481],
       [0.66791672, 0.69540793, 0.7906791 , 0.74079674, 0.75139421,
        0.75080746, 0.68582624, 0.63543165, 0.59522635, 0.65718603]])

when I execute:

sns_plot = sns.heatmap(m)

I get the following error:

ValueError: left cannot be >= right

What am I doing wrong?

like image 726
Kenny Smith Avatar asked Mar 27 '26 09:03

Kenny Smith


1 Answers

Using np.array this worked perfectly for me

import numpy as np

m = np.array([[0.91992515, 0.978894  , 0.98183531, 0.99085009, 0.98576438,
        0.99062014, 0.9931621 , 0.99088091, 0.92711413, 0.78091824],
       [0.92729372, 0.97037023, 0.98044407, 0.97998279, 0.97441202,
        0.99145925, 0.98606282, 0.99012506, 0.94134074, 0.79332185],
       [0.92185014, 0.95902878, 0.97929859, 0.98272425, 0.98107767,
        0.98998082, 0.99233872, 0.9882673 , 0.92030007, 0.80480009],
       [0.91204637, 0.96461374, 0.97577399, 0.98063707, 0.96949238,
        0.99135023, 0.98836327, 0.98504972, 0.97783262, 0.77362221],
       [0.93386984, 0.97553176, 0.97664225, 0.98727471, 0.98023629,
        0.98472446, 0.98551005, 0.98410082, 0.9551242 , 0.77246934],
       [0.93045634, 0.97707605, 0.99085528, 0.98433924, 0.98237419,
        0.99572343, 0.99173379, 0.98824054, 0.96632308, 0.76564348],
       [0.93682766, 0.97289765, 0.98349541, 0.99275345, 0.98538131,
        0.99283469, 0.99232531, 0.98699528, 0.95912874, 0.91011888],
       [0.89040715, 0.96955484, 0.97332346, 0.96521449, 0.97545224,
        0.98275667, 0.98541254, 0.97983998, 0.90709436, 0.88003486],
       [0.95064926, 0.9512195 , 0.96981376, 0.9641239 , 0.98085016,
        0.95860326, 0.9453789 , 0.89857048, 0.94533682, 0.67875481],
       [0.66791672, 0.69540793, 0.7906791 , 0.74079674, 0.75139421,
        0.75080746, 0.68582624, 0.63543165, 0.59522635, 0.65718603]])



sns_plot = seaborn.heatmap(m)
like image 184
DDaly Avatar answered Mar 28 '26 23:03

DDaly



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!