1

The example script produces a simple figure. When hovering over the data the coordinates in the corner are (x=, y=).

No coordinates for the plot

While hovering the colorbar shows something, but the data without the coordinate is interpreted as y.

Coordinates for the colorbar

import seaborn as sns
import numpy as np
import matplotlib.pyplot as plt

data = np.array([[15, 10], [20, 10]])

sns.heatmap(data, linewidth=0.01, square=True)
plt.show()

Environment Versions:

Ubuntu        22.04.2 LTS
python        3.11
matplotlib    3.7.1
numpy         1.24.3
seaborn       0.12.2

I tried to dig around the attributes of the axes of the seaborn generated figure, but no luck. I didn't find other stackoverflow/other forum questions when searching to solve this.

EDIT: Of course the cursor is not visible when taking a snippet of the screen -.-

Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
  • Does this answer your question? [matplotlib values under cursor](https://stackoverflow.com/questions/14754931/matplotlib-values-under-cursor) – jared Jun 12 '23 at 17:16
  • It would appear that seaborn heatmaps just do not have cursor hover functionality. Plots of this sort are meant to be saved as PDFs or images, which are not interactive. You can add that functionality, but for that sort of plot, I am not sure it is necessary. – jared Jun 12 '23 at 17:17
  • It's unfortunate that the cursor don't work for heatmaps. The reason why I need this is I wanted to make an interactive data viewer for (x, y, z) data and I was planning to use PyQT5, seaborn and NavigationToolbar2QT from matplotlib. Would you have an example of how to add the cursor functionality? – Lullapalanza Jun 12 '23 at 17:21
  • The linked solution seems to explain how to do that. – jared Jun 12 '23 at 17:31
  • 1
    Use `matplotlib.pyplot.imshow` or `matplotlib.axes.Axes.imshow` instead. seaborn is just a high-level API for matplotlib. e.g. [`plt.imshow(data)`](https://i.stack.imgur.com/ol1qi.png) – Trenton McKinney Jun 12 '23 at 17:54

0 Answers0