Matplotlib - plot_surface : get the x,y,z values written in the bottom right corner

前端 未结 2 788
故里飘歌
故里飘歌 2021-01-06 13:34

I am a quite new user of matplotlib. When plotting a surface (3D) with matplotlib and plot_surface, a window appears with the graph. In that windows, on the bottom right cor

2条回答
  •  一整个雨季
    2021-01-06 13:45

    I tried @Thilo's answer and received only a single float. Using Python 3.8 and Matplotlib version 3.2.1.

    Modified his function to this

    def getxyz(event):
        s = ax.format_coord(event.xdata, event.ydata)
        out = [float(x.split('=')[1].strip()) for x in s.split(',')]
        print(out)
        return out
    

    Many thanks, because without that answer I would never knew something like format_coord exist.

提交回复
热议问题