FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

`close_event` deprecated warning. · Issue #24602 · matplotlib/matplotlib · GitHub

Repository navigation

close_event deprecated warning. #24602

Closed

Description

Bug summary

The attached code gives the warning seen below.

If this is intended, should not the close documentation include such a warning too?
If not, is there a quick workaround to ignore this warning?

Code for reproduction

import matplotlib.pyplot as plt                                                                         
import mpl_toolkits.mplot3d.axes3d as axes3d                                                            
import numpy as np                                                                                      
                                                                                                        
def plot_sphere():                                                                                      
                                                                                                        
    # Spherical grid.                                                                                   
    th = np.linspace(0., np.pi, 100)                                                                    
    ph = np.linspace(0., 2. * np.pi, 300)                                                               
    theta, phi = np.meshgrid(th, ph)                                                                    
                                                                                                        
    # Plot sphere.                                                                                      
    x_sphere = np.sin(theta) * np.cos(phi)                                                              
    y_sphere = np.sin(theta) * np.sin(phi)                                                              
    z_sphere = np.cos(theta)                                                                            
                                                                                                        
    fig = plt.figure()                                                                                  
    ax = fig.add_subplot(1, 1, 1, projection='3d')                                                      
    ax.plot_surface(x_sphere, y_sphere, z_sphere, color='blue')                                         
    plt.savefig("Test.pdf", bbox_inches="tight")                                                        
    plt.close(fig)                                                                                      
                                                                                                        
                                                                                                        
def run():                                                                                              
    plot_sphere()                                                                                       
                                                                                                        
                                                                                                        
run()

Actual outcome

MatplotlibDeprecationWarning: The close_event function was deprecated in Matplotlib 3.6 and will be removed two minor releases later. Use callbacks.process('close_event', CloseEvent(...)) instead.

Expected outcome

No warning.

Additional information

No response

Operating system

Ubuntu 22

Matplotlib Version

3.6.2

Matplotlib Backend

GTK4Agg

Python version

3.10

Jupyter version

No response

Installation

pip

Activity

  1. added this to the v3.6.3 milestone on Dec 3, 2022
  2. added
    Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
    on Dec 3, 2022
  3. tacaswell commented on Dec 3, 2022

    Member

    That should not be warning and we did not mean to deprecated plt.close.

    This appears to be a bug specific to the gtk backend.

  4. added a commit that references this issue on Dec 3, 2022
    4e7dd10
  5. added a commit that references this issue on Dec 5, 2022
    cdeed5f
  6. added a commit that references this issue on Dec 19, 2022
    587eb8a
  7. added 3 commits that reference this issue on Apr 19, 2026
    1827b41
    df21d43
    c4e9bf3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    GUI: gtkRelease criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL