RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
pythonMatplotlib底图中鼠标滑过显示隐藏内容的实例代码-创新互联

在使用Matplotlib画图过程中,有些内容必须鼠标点击或者划过才可以显示,这个问题可以依赖于annotate(s='str' ,xy=(x,y) ,xytext=(l1,l2) ,..)这个函数,其中s 为注释文本内容 , xy 为被注释的坐标点, xytext 为注释文字的坐标位置,其他参数可自行百度哈。当鼠标滑过时候,将其设置为可见,默认情况下为隐藏。下面是一个小例子:

成都创新互联是专业的祁连网站建设公司,祁连接单;提供网站设计制作、成都网站制作,网页设计,网站设计,建网站,PHP网站建设等专业做网站服务;采用PHP框架,可快速的进行祁连网站开发网页制作和功能扩展;专业做搜索引擎喜爱的网站,专业的做网站团队,希望更多企业前来合作!
# -*- coding: UTF-8 -*-
import matplotlib.pyplot as plt
fig = plt.figure()
po_annotation = []
for i in range(0, 10):
  x = i
  y = x**2
  point, = plt.plot(x, y, 'o')
  annotation = plt.annotate(('x='+str(x), 'y='+str(y)), xy=(x+0.1, y+0.1), xycoords='data', xytext=(x+0.7, y+0.7),
                textcoords='data', horizontalalignment="left",
                arrowprops=dict(arrow,connection),
                bbox=dict(box, facecolor="w",edgecolor="0.5", alpha=0.9)
                )
  annotation.set_visible(False)
  po_annotation.append([point, annotation])
def on_move(event):
  visibility_changed = False
  for point, annotation in po_annotation:
    should_be_visible = (point.contains(event)[0] == True)
    # print(point.contains(event)[0])
    if should_be_visible != annotation.get_visible():
      visibility_changed = True
      annotation.set_visible(should_be_visible)
  if visibility_changed:
    plt.draw()
on_move_id = fig.canvas.mpl_connect('motion_notify_event', on_move)
plt.show()

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


名称栏目:pythonMatplotlib底图中鼠标滑过显示隐藏内容的实例代码-创新互联
当前路径:http://sczitong.cn/article/hpdhh.html