我正在绘制一些看起来像
931,Oxfordshire,9314125,123255,Larkmead School,Abingdon,125,124,20,SUPP,8
931,Oxfordshire,9314126,123256,John Mason School,Abingdon,164,164,25,6,16
931,Oxfordshire,9314127,123257,Fitzharrys School,Abingdon,150,149,9,0,11
931,Oxfordshire,9316076,123298,Our Lady's Abingdon,Abingdon,57,57,SUPP,SUPP,16
我的基本步骤是
^{pr2}$不过,当我把鼠标移到图表上时,我真的很想知道每个学校的名称,这样我就可以浏览数据了。有办法吗?在
为了插入我自己的项目,看看
mpldatacursor
:https://github.com/joferkington/mpldatacursor作为一个基本的例子,只要调用
datacursor(hover=True, point_labels=df['E'])
就可以让你90%的时间得到你想要的东西。例如,以上面的代码片段为例:当行悬停在上面时,我们会得到一个弹出标签。在
但是,根据设计,默认行为是在鼠标悬停/单击该行时显示弹出窗口。因此,当使用
point_labels
选项时,结果可能不是您所想的那样:如果只希望在顶点悬停时显示弹出窗口,则可以使用类似的解决方法:(在下一版本中,将有一个仅在顶点处显示弹出窗口的选项,因此将来不再需要此解决方法。)
^{pr2}$此外,您可能希望只显示相关学校,而不是x、y坐标等。要更改此设置,请使用自定义的
formatter
函数:最后,你可能需要一个白色的盒子,上面有一个漂亮的箭头和一个不同的相对位置:
最后一个例子就是把它们放在一个可运行的版本中:
相关问题 更多 >
编程相关推荐