question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

sns.heatmap annotation

See original GitHub issue

Hi there!

I just discovered that in the dev version you can annotate a heat map with the contents of another matrix (wohoo!). I’ve google around (with no success) to see if you can do two things:

  • Conditional annotation. In my case, I’ve got a big matrix with a lot of 0.0 values, and those are boring. I’d like to annotate only those cells whose value is != 0. Is that possible?
  • Annotate every cell even if xticklabels and yticklabels are set to something other than True. I’ve noticed that if I change them (to avoid text cluttering in the x and y labels), the annotations on the map are also displayed with an offset. Is it possible to turn that off?

Thanks for any comments and keep up prettyfing matplotlib! 😄

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
MartinHjelmcommented, Oct 24, 2017

Question: with the mask the annotation and values are not shown if cell is true. Is it possible to just keep the values an remove the annotation? I have a matrix where I want to annotate the n largest values for each row.

0reactions
diallobakary4commented, Sep 8, 2018

Thank you @jeiros . I want something similar. I have seen another solution: to access the text object and modify it.

for text in sns_clustermap.texts:
    text.set_size(14)
    if text.get_text() == '2': # conditional for cells one would like to highlight. This can then be changed to the highest value...
        text.set_size(25)
        text.set_weight('bold')
        text.set_style('italic')
Read more comments on GitHub >

github_iconTop Results From Across the Web

seaborn.heatmap — seaborn 0.12.1 documentation
Plot rectangular data as a color-encoded matrix. This is an Axes-level function and will draw the heatmap into the currently-active Axes if none...
Read more >
Custom Annotation Seaborn Heatmap - python - Stack Overflow
I'm using Seaborn in Python to create a Heatmap. I'm able to annotate the cells with the values passed in, but I'd like...
Read more >
How to annotate each cell of a heatmap in Seaborn?
Use sns.heatmap() to plot a dataframe (Step 2) with annot=True flag in the argument. To display the figure, use show() method.
Read more >
Customize seaborn heatmap - Python Graph Gallery
Annotate each cell with value ... The heatmap can show the exact value behind the color. To add a label to each cell,...
Read more >
How to add text in a heatmap cell annotations using seaborn ...
How to add text in a heatmap cell annotations using seaborn in Python ? · Import module · Create data or load dataset...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found