Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Bug]: Custom backend stopped working in 3.6.2 #24524

Copy link
Copy link
Closed
@mrzv

Description

@mrzv
Issue body actions

Bug summary

A custom backend that's been working for a few years without a problem, stopped working under Matplotlib 3.6.2.

Code for reproduction

# mpl.py
from matplotlib._pylab_helpers import Gcf
from matplotlib.backend_bases import (_Backend, FigureCanvasBase, FigureManagerBase)
from matplotlib.backends.backend_agg import FigureCanvasAgg

class MyFigureManager(FigureManagerBase):
    def show(self):
        print("MyFigureManager.show()")

@_Backend.export
class MyBackend(_Backend):
    FigureCanvas  = FigureCanvasAgg
    FigureManager = MyFigureManager

    def show(*args, **kwargs):
        print("MyBackend.show()")
        _Backend.show(*args, **kwargs)
        print("MyBackend.show() after _Backend")
# plot_mpl.py
import matplotlib
matplotlib.use("module://mpl")

import matplotlib.pyplot as plt

plt.plot([1,2,3,4,5])
plt.show()

Actual outcome

Running using Matplotlib 3.5.3, this outputs:

MyBackend.show()
MyFigureManager.show()
MyBackend.show() after _Backend

But running using 3.6.2, I get:

MyBackend.show()
.../mpl.py:16: UserWarning: Matplotlib is currently using module://mpl, which is a non-GUI backend, so cannot show the figure.
  _Backend.show(*args, **kwargs)
MyBackend.show() after _Backend

In particular, MyFigureManager.show() is never called.

Expected outcome

Same behavior under both versions.

Operating system

macOS

Matplotlib Version

3.5.3, 3.6.2

Python version

3.10.8

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.