You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feature Request: Add annotations to heatmaps (imshow or pcolor*) #10956
I noticed that imshow or pcolor* do not have an option to add annotations to each box.
Currently, MPL creates heatmaps such as the one below:
However, MPL does not have the ability to add values to each grid box such as the image below:
This seems like a standard feature, which can enhance the readability of these heatmaps. In addition, this can be very helpful when values are 0.01 apart. It can help the user distinguish the heatmap values more efficiently. A proposed solution to turn on these values would look like plt.pcolor(data, showvalues=true).
data = ... # 2D numpy array
ax.imshow(data)
for i in range(data.shape[0]):
for j in range(data.shape[1]):
ax.text(j, i, "{:.2f}".format(data[i,j]), ha="center", va="center")
Plus you have all the freedom to do the labeling just the way you wish instead of relying on some automatism.
Also note that seaborn allows autolabeling of their heatmaps. The reason is that those heatmaps are categorical by design, while pcolor and imshow are general purpose image plots. And you wouldn't want to label the latest image you took with your camera that way I guess.
So I'm a bit sceptical if this is really needed, given how easy it is to invoke manually.
Activity
ImportanceOfBeingErnest commentedon Apr 4, 2018
Labeling an imshow plot is as easy as
Plus you have all the freedom to do the labeling just the way you wish instead of relying on some automatism.
Also note that seaborn allows autolabeling of their heatmaps. The reason is that those heatmaps are categorical by design, while pcolor and imshow are general purpose image plots. And you wouldn't want to label the latest image you took with your camera that way I guess.
So I'm a bit sceptical if this is really needed, given how easy it is to invoke manually.
efiring commentedon Apr 4, 2018
Maybe this should be in a gallery example or addition to a tutorial.
ImportanceOfBeingErnest commentedon Apr 14, 2018
There is now a heatmap example in the docs (via #11017).