Tplinter中带有嵌入式pcolor图形的Mplcursor

问题描述

我正在pcolor图形上绘制一个值数组,然后将其嵌入到tkinter窗口中。一切顺利,绘图与工具栏一起显示,但是当我尝试使用mplcursors在图中显示绘图单元的值时,出现以下错误

Python\python38\lib\site-packages\mplcursors\_pick_info.py:141: UserWarning: Pick support for polyCollection is missing. warnings.warn(f"Pick support for {type(artist).__name__} is missing.")

在这里和Google的论坛上进行了快速搜索,但无法弄清为什么mplcursors无法找到要显示的数据。

以下代码是绘制图形的功能

def plot(yaxis,xaxis,array):
    # custom colormap deFinition,colours in Hex
    cmap = clr.LinearSegmentedColormap.from_list('custom_GnRd',['#ff0000','#00ff11'],N=256)

    fig = matplotlib.figure.figure()
    ax0 = fig.add_subplot()
    pcp = ax0.pcolor(yaxis,array,cmap=cmap,vmin=0,vmax=1,linewidth=1,edgecolor='k',)
    ax0.set_ylabel("ylabel")
    ax0.set_xlabel("xlabel")
    fig.suptitle(fileTitle)



    # creates the figure under tkinter window
    canvas = figureCanvasTkAgg(fig,root)
    mplcursors.cursor(pcp)
    canvas.draw()

    # placing canvas in tkinter window
    canvas.get_tk_widget().pack(side=tkinter.TOP,fill=tkinter.BOTH,expand=1)

    # creates the matplotlib toolbar under tkinter window
    toolbar = NavigationToolbar2Tk(canvas,root)
    toolbar.update()

    # placing toolbar in tkinter window
    canvas.get_tk_widget().pack(side=tkinter.TOP,expand=1)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)