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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:48:06+00:00 2026-06-17T20:48:06+00:00

I am using a matplotlib figure embedded in a WxPython GUI to present some

  • 0

I am using a matplotlib figure embedded in a WxPython GUI to present some data.
The content of the figure (data displayed) changes constantly in function of the buttons clicked, …

The data are of two types.

1) contour lines

self.axes.contour(x_scale_map,y_scale_map,matrix,cl,cmap=my_cmap,extent=0,matrix.shape[1]-1,0,matrix.shape[0]-1))

This is relatively slow to load (~1s), but does not change very often.

2) On top of this contour, I plot for instance some lines

self.axes.axhline(y,color='black')

These lines are obviously drawn instantly and change often in function of what the user clicks. In these situations, previously drawn lines need to disappear and new ones need to appear, while the contour map stays unchanged.

Now, my problem is as follows. I have not found a way to remove only the lines and not the contour. The only way to obtain the desired result seems to be doing:

self.axes.clear()

and then replot both the contour and the new lines. But as mentioned, reloading the contour each time is slow and thus annoying.

Is there a way to clear only the lines from the figure?
I have tried to use superimposed subplots by doing something like:

self.axes1 = self.fig.add_subplot(111)
self.axes2 = self.fig.add_subplot(111)
self.axes1.contour(...)
self.axes2.axhline(y,color='black')
self.axes2.clear()

but this last line clears the entire figure.

Does anyone know how to achieve the desired functionality?
Thanks

  • 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-17T20:48:08+00:00Added an answer on June 17, 2026 at 8:48 pm

    The following Q&A gives the solution to this problem.

    In other words, to be able to remove a line from the figure:

    1) keep track of the line by storing its reference when drawing it:

    my_line = self.axes.axhline(y,color='black')
    

    2) the removal is then done as follows:

    my_line.remove()
    del my_line
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using matplotlib to plot data as a function of time in hh:mm:ss.ms format
I am using matplotlib and Tkinter to plot some data. When I press a
I'm using matplotlib to plot some data as 2D curves in a 3D axes.
I am using Matplotlib to create an image based on some data. All of
I am using matplotlib inside of a wxpython GUI. In short, I have plotted
I am plotting things using matplotlib and Basemap (within a wxpython gui). Currently, my
Is there a function for drawing a caption box underneath a figure/graph using matplotlib?
I am encountering some strange behavior with using the matplotlib.pyplot ginput() function to store
I am using matplotlib and numpy to make a polar plot. Here is some
I am using matplotlib and I'm finding some problems when trying to plot large

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.