Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8577477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:10:08+00:00 2026-06-11T20:10:08+00:00

I am currently employing this code to have pop up annotatations on a map

  • 0

I am currently employing this code to have pop up annotatations on a map when i click on a point in a Basemap Matplotlib Plot.

dcc = DataCursor(self.figure.gca())
self.figure.canvas.mpl_connect('pick_event',dcc)
plot_handle.set_picker(5)
self.figure.canvas.draw()

class DataCursor(object):

    import matplotlib.pyplot as plt

    text_template = 'x: %0.2f\ny: %0.2f' 
    x, y = 0.0, 0.0 
    xoffset, yoffset = -20 , 20
    text_template = 'A: %s\nB: %s\nC: %s'


    def __init__(self, ax): 
        self.ax = ax 
        self.annotation = ax.annotate(self.text_template,  
                xy=(self.x, self.y), xytext=(0,0),
                textcoords='axes fraction', ha='left', va='bottom', fontsize=10,
                bbox=dict(boxstyle='round,pad=0.5', fc='yellow', alpha=1), 
                arrowprops=dict(arrowstyle='->', connectionstyle='arc3,rad=0') 
                ) 
        self.annotation.set_visible(False)
        self.annotation.draggable()


    def __call__(self, event):

        self.event = event 
        self.x, self.y = event.mouseevent.xdata, event.mouseevent.ydata

        if self.x is not None:
            glim = pickle.load(open("ListA.py","rb"))
            tlim = pickle.load(open("ListB.py","rb"))
            vlim = pickle.load(open("ListC.py","rb"))
            a = glim[event.ind[0]] # ['Name'][event.ind[0]]
            b = tlim[event.ind[0]]
            c = vlim[event.ind[0]]
            temp_temp=self.text_template % (a, b, c)
            if temp_temp == self.annotation.get_text() and self.annotation.get_visible(): 
                self.annotation.set_visible(False) 
                event.canvas.draw() 
                return 
            self.annotation.xy = self.x, self.y
            self.annotation.set_text(self.text_template % (a, b, c))
            self.annotation.set_visible(True)

            event.canvas.draw()

What I am wondering, is how to show the annotations using mouse hover rather than clicking on a point?

I have seen “motion_notify_event” but it seems the code gets errors when i move the mouse around the plot area. Any Thoughts?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T20:10:09+00:00Added an answer on June 11, 2026 at 8:10 pm

    Take a look at this question and demo :

    from matplotlib.pyplot import figure, show
    import numpy as npy
    from numpy.random import rand
    
    
    if 1: # picking on a scatter plot (matplotlib.collections.RegularPolyCollection)
    
        x, y, c, s = rand(4, 100)
        def onpick3(event):
            ind = event.ind
            print 'onpick3 scatter:', ind, npy.take(x, ind), npy.take(y, ind)
    
        fig = figure()
        ax1 = fig.add_subplot(111)
        col = ax1.scatter(x, y, 100*s, c, picker=True)
        #fig.savefig('pscoll.eps')
        fig.canvas.mpl_connect('pick_event', onpick3)
    
    show()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code here please, which permits me to import data from a
Actually I am studying this algorithm and I have been exploring his code (which
If I have this code: $numbers = array_unique(explode(,, file_get_contents('text.txt'))); print_r($numbers); With this text file:
I'm currently exploring powershell capabilities, but I have encountered a problem that I have
currently, I`m implementing a map App with Mono4Droid and there I`m using a WebView
Currently, I'm working on a project where I have a server - client relationship
Currently I have 2 ways of displaying images in a cell, which way will
Hey, long story short I have inherited some terrible code. As a result a
I'm employing color in a current AS3 project, and have come across what appears
We currently have a system that displays a page tabular data on the screen

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.