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

  • SEARCH
  • Home
  • 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 8268633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:57:22+00:00 2026-06-08T05:57:22+00:00

I want to know how to create a popup box in a basemap plot.

  • 0

I want to know how to create a popup box in a basemap plot. When I hover my mouse over a location , it should trigger the popup box.

Is this possible?

  • 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-08T05:57:24+00:00Added an answer on June 8, 2026 at 5:57 am

    Yes it is possible thanks to matplotlib’s event handling framework. I couldn’t find an already written example which does what you are particularly interested in so I wrote one (which I will put forward for inclusion in the matplotlib source).

    I would read http://matplotlib.sourceforge.net/users/event_handling.html thoroughly to best understand what is going on. Please note that although it sounds like the perfect solution “pick_event” is for mouse clicks -not for mouse over- events and doesn’t work in this case.

    My code, which could be objectified very nicely should one want, looks like:

    import matplotlib.pyplot as plt
    
    fig = plt.figure()
    ax = plt.axes()
    
    
    points_with_annotation = []
    for i in range(10):
        point, = plt.plot(i, i, 'o', markersize=10)
    
        annotation = ax.annotate("Mouseover point %s" % i,
            xy=(i, i), xycoords='data',
            xytext=(i + 1, i), textcoords='data',
            horizontalalignment="left",
            arrowprops=dict(arrowstyle="simple",
                            connectionstyle="arc3,rad=-0.2"),
            bbox=dict(boxstyle="round", facecolor="w", 
                      edgecolor="0.5", alpha=0.9)
            )
        # by default, disable the annotation visibility
        annotation.set_visible(False)
    
        points_with_annotation.append([point, annotation])
    
    
    def on_move(event):
        visibility_changed = False
        for point, annotation in points_with_annotation:
            should_be_visible = (point.contains(event)[0] == True)
    
            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()
    

    Hopefully everything should be fairly readable. A high level overview of the code goes:

    • Create a list of [point, annotation] pairs, where by default the annotation is not visible
    • Register a function, “on_move”, to be called every time there is mouse motion detected
    • The on_move function iterates through each point and annotation, if the mouse is now over one of the points, make its associated annotation visible, if it is not, make it invisible. (the contains method is documented here)

    Screenshot of the result

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a very newbie question. I want to know how to create a
I want to create a customized popup over the android's incoming call screen where
I want to know how to create a private attribute in a Javascript class.
I want to know how to create an image column in a SQL Server
I want to know how to create a label that contains two icons, one
I'm using multi-table-inheritance , and want to know how to create an inherited type
I want to know what happens when I create an instance of a ServiceHost
I want to know if PHPExcel can: Create Excel spreadsheets with embeded image. The
I want to know if I can create a WebBrowser through code in Vb.NET,
I want to know which FamilyName was used by Windows to create a font

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.