Seaborn: masked heatmap color bar does not limit ranges

Created on 4 Dec 2018  路  1Comment  路  Source: mwaskom/seaborn

The masked heat-map colorbar shows the range of even the masked cells?

df = pd.read_fwf(io.StringIO("""Cl1  Cl2  Cl3  Sum
0.7  0.9  0.9  2.5
0.8  1.5  0.9  3.2
2.4  2.8  2.1  7.3"""))

mask = np.zeros((3, 4))
mask[:,3] = True
ax = sns.heatmap(df, mask=mask, annot=True,
                 annot_kws={"size": 20, "color":"g"})


for (j,i), label in np.ndenumerate(df.values):
    if i == 3:
        ax.text(i+0.5, j+0.5, label, 
                fontdict=dict(ha='center',  va='center',
                                         color='g', fontsize=20))

capture

There is no values above 3 in the unmasked zone but the colormap shows values above this range! I know we can clip the colorbar, but it would be easier if the seaborn manages it itself!

Kind regards

https://stackoverflow.com/questions/53606027/exclude-a-column-from-seaborn-heatmap-formatting-but-keep-in-the-map/53606576#53606576

Plateform = windows 10 64

alabaster                 0.7.12                     py_0    conda-forge
asn1crypto                0.24.0                py36_1003    conda-forge
astroid                   2.1.0                 py36_1000    conda-forge
attrs                     18.2.0                     py_0    conda-forge
babel                     2.6.0                      py_1    conda-forge
backcall                  0.1.0                      py_0    conda-forge
blas                      1.0                         mkl
bleach                    3.0.2                      py_0    conda-forge
ca-certificates           2018.03.07                    0    anaconda
certifi                   2018.10.15               py36_0    anaconda
cffi                      1.11.5          py36hfa6e2cd_1001    conda-forge
chardet                   3.0.4                 py36_1003    conda-forge
cloudpickle               0.6.1                      py_0    conda-forge
colorama                  0.4.0                      py_0    conda-forge
conda                     4.5.11                   py36_0
conda-env                 2.6.0                         1    conda-forge
console_shortcut          0.1.1                         3
cryptography              2.3.1           py36h74b6da3_1000    conda-forge
cycler                    0.10.0                     py_1    conda-forge
decorator                 4.3.0                      py_0    conda-forge
docutils                  0.14                  py36_1001    conda-forge
entrypoints               0.2.3                 py36_1002    conda-forge
fastcache                 1.0.2           py36hfa6e2cd_1001    conda-forge
freetype                  2.9.1             he8b6a0d_1004    conda-forge
future                    0.17.0                py36_1000    conda-forge
icc_rt                    2017.0.4             h97af966_0
icu                       58.2                 ha66f8fd_1    anaconda
idna                      2.7                   py36_1002    conda-forge
imagesize                 1.1.0                      py_0    conda-forge
intel-openmp              2019.1                      144
ipykernel                 5.1.0           py36h39e3cac_1001    conda-forge
ipython                   7.2.0           py36h39e3cac_1000    conda-forge
ipython_genutils          0.2.0                      py_1    conda-forge
ipywidgets                7.4.2                      py_0    conda-forge
isort                     4.3.4                 py36_1000    conda-forge
jedi                      0.13.1                py36_1000    conda-forge
jinja2                    2.10                       py_1    conda-forge
jpeg                      9c                hfa6e2cd_1001    conda-forge
jsonschema                3.0.0a3               py36_1000    conda-forge
jupyter                   1.0.0                      py_1    conda-forge
jupyter_client            5.2.3                      py_1    conda-forge
jupyter_console           6.0.0                      py_0    conda-forge
jupyter_core              4.4.0                      py_0    conda-forge
keyring                   17.0.0                py36_1000    conda-forge
kiwisolver                1.0.1           py36he980bc4_1002    conda-forge
lazy-object-proxy         1.3.1           py36hfa6e2cd_1000    conda-forge
libiconv                  1.15              hfa6e2cd_1003    conda-forge
libpng                    1.6.36            h7602738_1000    conda-forge
libsodium                 1.0.16               h9d3ae62_0    anaconda
libxml2                   2.9.8             h9ce36c8_1005    conda-forge
libxslt                   1.1.32            heafd4d3_1002    conda-forge
lxml                      4.2.5           py36heafd4d3_1000    conda-forge
m2w64-gcc-libgfortran     5.3.0                         6
m2w64-gcc-libs            5.3.0                         7
m2w64-gcc-libs-core       5.3.0                         7
m2w64-gmp                 6.1.0                         2
m2w64-libwinpthread-git   5.0.0.4634.697f757               2
markupsafe                1.1.0           py36hfa6e2cd_1000    conda-forge
matplotlib                3.0.2           py36h8a2030e_1001    conda-forge
matplotlib-base           3.0.2           py36h3e3dc42_1001    conda-forge
mccabe                    0.6.1                      py_1    conda-forge
menuinst                  1.4.14                py36_1000    conda-forge
mistune                   0.8.4           py36hfa6e2cd_1000    conda-forge
mkl                       2018.0.3                      1
mkl_fft                   1.0.10                   py36_0    conda-forge
mkl_random                1.0.2                    py36_0    conda-forge
mpmath                    1.0.0                      py_1    conda-forge
msys2-conda-epoch         20160418                      1
nbconvert                 5.3.1                      py_1    conda-forge
nbformat                  4.4.0                      py_1    conda-forge
notebook                  5.7.2                 py36_1000    conda-forge
numpy                     1.15.4           py36ha559c80_0
numpy-base                1.15.4           py36h8128ebf_0
numpydoc                  0.8.0                      py_1    conda-forge
obspy                     1.1.0           py36h452e1ab_1002    conda-forge
openssl                   1.0.2p               hfa6e2cd_0    anaconda
packaging                 18.0                       py_0    conda-forge
pandas                    0.23.4          py36h830ac7b_1000    conda-forge
pandoc                    2.2.3.2                       0    anaconda
pandocfilters             1.4.2                      py_1    conda-forge
parso                     0.3.1                      py_0    conda-forge
patsy                     0.5.1                    py36_0    anaconda
pickleshare               0.7.5                 py36_1000    conda-forge
pip                       18.1                  py36_1000    conda-forge
prometheus_client         0.4.2                      py_0    conda-forge
prompt_toolkit            2.0.7                      py_0    conda-forge
psutil                    5.4.8           py36hfa6e2cd_1000    conda-forge
pycodestyle               2.4.0                      py_1    conda-forge
pycosat                   0.6.3           py36hfa6e2cd_1001    conda-forge
pycparser                 2.19                       py_0    conda-forge
pyflakes                  2.0.0                      py_0    conda-forge
pygments                  2.3.0                      py_0    conda-forge
pylint                    2.2.2                 py36_1000    conda-forge
pyopenssl                 18.0.0                py36_1000    conda-forge
pyparsing                 2.3.0                      py_0    conda-forge
pyqt                      5.6.0           py36h764d66f_1007    conda-forge
pyrsistent                0.14.7          py36hfa6e2cd_1000    conda-forge
pysocks                   1.6.8                 py36_1002    conda-forge
python                    3.6.6                he025d50_0    conda-forge
python-dateutil           2.7.5                      py_0    conda-forge
pytz                      2018.7                     py_0    conda-forge
pywin32                   224             py36hfa6e2cd_1000    conda-forge
pywin32-ctypes            0.2.0                 py36_1000    conda-forge
pywinpty                  0.5.4                 py36_1002    conda-forge
pyzmq                     17.1.2          py36hf576995_1001    conda-forge
qt                        5.6.2                h2639256_8    conda-forge
qtawesome                 0.5.3              pyh8a2030e_0    conda-forge
qtconsole                 4.4.3                      py_0    conda-forge
qtpy                      1.5.2              pyh8a2030e_0    conda-forge
requests                  2.20.1                py36_1000    conda-forge
rope                      0.10.7                     py_1    conda-forge
ruamel_yaml               0.15.71         py36hfa6e2cd_1000    conda-forge
scipy                     1.1.0            py36h4f6bf74_1
seaborn                   0.9.0                    py36_0    anaconda
send2trash                1.5.0                      py_0    conda-forge
setuptools                40.6.2                   py36_0    conda-forge
sip                       4.18.1           py36h6538335_0    conda-forge
six                       1.11.0                py36_1001    conda-forge
snowballstemmer           1.2.1                      py_1    conda-forge
sphinx                    1.8.2                 py36_1000    conda-forge
sphinxcontrib             1.0                      py36_1
sphinxcontrib-websupport  1.1.0                      py_1    conda-forge
spyder                    4.0.0b1                  py36_1    spyder-ide
spyder-kernels            1.1.0                      py_0    spyder-ide
spyder-notebook           0.1.3                    py36_0    spyder-ide
sqlalchemy                1.2.14          py36hfa6e2cd_1000    conda-forge
sqlite                    3.26.0            hfa6e2cd_1000    conda-forge
statsmodels               0.9.0            py36h452e1ab_0    anaconda
sympy                     1.3                   py36_1000    conda-forge
terminado                 0.8.1                 py36_1001    conda-forge
testpath                  0.4.2                 py36_1000    conda-forge
tornado                   5.1.1           py36hfa6e2cd_1000    conda-forge
traitlets                 4.3.2                 py36_1000    conda-forge
typed-ast                 1.1.0           py36hfa6e2cd_1000    conda-forge
urllib3                   1.23                  py36_1001    conda-forge
vc                        14.1                 h21ff451_3    anaconda
vs2015_runtime            15.5.2                        3    anaconda
wcwidth                   0.1.7                      py_1    conda-forge
webencodings              0.5.1                      py_1    conda-forge
wheel                     0.32.3                   py36_0    conda-forge
widgetsnbextension        3.4.2                 py36_1000    conda-forge
win_inet_pton             1.0.1                 py36_1002    conda-forge
wincertstore              0.2                   py36_1002    conda-forge
winpty                    0.4.3                         4    anaconda
wrapt                     1.10.11         py36hfa6e2cd_1001    conda-forge
yaml                      0.1.7             hfa6e2cd_1001    conda-forge
zeromq                    4.2.5                he025d50_1    anaconda
zlib                      1.2.11            h2fa13f4_1003    conda-forge

Most helpful comment

>All comments

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rrbarbosa picture rrbarbosa  路  3Comments

Bercio picture Bercio  路  3Comments

amelio-vazquez-reina picture amelio-vazquez-reina  路  3Comments

bondarevts picture bondarevts  路  3Comments

chanshing picture chanshing  路  3Comments