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 8119413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:47:47+00:00 2026-06-06T04:47:47+00:00

I have a two panel wxPython GUI set up. In my right panel, I

  • 0

I have a two panel wxPython GUI set up. In my right panel, I have a map display using Basemap. On this basemap (of the United States) I plot a scatter plot of different cities. I would like to be able to click on these dots and have a pop up window within my GUI that gives some information relative to that dot I select (ex. City, lat/long, etc. — I would have all this info stored in a list or other means).

I have come across AnnoteFinder, but this does not seem to work inside my GUI (it will work if i use Basemap by itelf and not in my 2 panel GUI). Also, this just puts some text on top of the dot — I would rather have a small window show up.

Example of my code so far:

#Setting up Map Figure
self.figure = Figure(None,dpi=75)
self.canvas = FigureCanvas(self.PlotPanel, -1, self.figure)
self.axes = self.figure.add_axes([0,0,1,1],frameon=False)
self.SetColor( (255,255,255) )

#Basemap Setup
self.map = Basemap(llcrnrlon=-119, llcrnrlat=22, urcrnrlon=-64,
                    urcrnrlat=49, projection='lcc', lat_1=33, lat_2=45,
                    lon_0=-95, resolution='h', area_thresh=10000,ax=self.axes)
self.map.drawcoastlines()
self.map.drawcountries()
self.map.drawstates()
self.figure.canvas.draw()

#Set up Scatter Plot
m = Basemap(llcrnrlon=-119, llcrnrlat=22, urcrnrlon=-64,
            urcrnrlat=49, projection='lcc', lat_1=33, lat_2=45,
            lon_0=-95, resolution='h', area_thresh=10000,ax=self.axes)

x,y=m(Long,Lat)

#Scatter Plot (they plot the same thing)
self.map.plot(x,y,'ro')
self.map.scatter(x,y,90)

self.figure.canvas.draw()

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-06T04:47:48+00:00Added an answer on June 6, 2026 at 4:47 am

    Check out this answer. Basically you set up a pick event that creates an annotation on the graph. This annotation can pop up as a tooltip-style text box.

    Note that this doesn’t produce a real GUI “window” (i.e., a dialog box or other control with close button, title bar, etc.), but just an annotation on the plot itself. However, from looking at the code you can see how it determines the artist (e.g., point) you’ve clicked on. Once you have that info, you could run whatever code you want with it, for instance creating a wxPython dialog instead of an annotation.

    Edit re your question about the last few lines: Based on your code, it looks like you’d want to do:

    pts = self.map.scatter(x, y, 90)
    self.figure.canvas.mpl_connect('pick_event', DataCursor(plt.gca()))
    pts.set_picker(5)
    

    Another edit re your question about having different text in the annotation: You may have to play around with the event object a bit to extract the information you want. As described at http://matplotlib.sourceforge.net/users/event_handling.html#simple-picking-example , different artist types (i.e., different kinds of plots) will provide different event information.

    I have some old code that does almost exactly what you described (displaying city name when a point on the map is clicked). I have to admit I don’t remember exactly how all of it works, but my code has this in the DataCursor:

    def __call__(self, event):
        self.event = event
        xdata, ydata = event.artist._offsets[:,0], event.artist._offsets[:,1]
        #self.x, self.y = xdata[event.ind], ydata[event.ind]
        self.x, self.y = event.mouseevent.xdata, event.mouseevent.ydata
        if self.x is not None:
            city = clim['Name'][event.ind[0]]
            if city == self.annotation.get_text() and self.annotation.get_visible():
                # You can click the visible annotation to remove it
                self.annotation.set_visible(False)
                event.canvas.draw()
                return
            self.annotation.xy = self.x, self.y
            self.annotation.set_text(city)
            self.annotation.set_visible(True)
            event.canvas.draw()
    

    clim['Name'] is the list of city names, and I was able to index into that using event.ind to get the city name corresponding to the picked point. Your code may need to be slightly different depending on the format of your data, but that should give you an idea.

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

Sidebar

Related Questions

I have two panels: main_panel child_panel The main_panel layout is set using: main_panel.setLayout(flowlayout) I
I have two radio buttons both set as async triggers for an update panel
I have a two panel layout using fragments. The left panel is 50dp wide
I have two questions. First I am using a spry accordion for this website
The situation is very simple, I have two panel. In the event of OnMouseOver
I have two panels in update panel. In panel1, there is button. If I
I currently have two panels within another large panel. The left panel is for
I have two panels that i wish to display to the user. I decided
I would like to have two-panel filemanager like mc or total commander. Do I
I have two controls in div wrapped into update panel. My code requires for

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.