Andrea Zonca Andrea Zonca - 4 years ago 231
Python Question

matplotlib contourf: get Z value under cursor

When I plot something with

, I see at the bottom of the plot window the current x and y values under the mouse cursor.
Is there a way to see also the z value?

Here an example

import matplotlib.pyplot as plt
import numpy as hp

Answer Source

The documentation example shows how you can insert z-value labels into your plot


Basically, it's

CS = plt.contour(X, Y, Z) 
plt.clabel(CS, inline=1, fontsize=10)
plt.title('Simplest default with labels')
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download