Skip to content

Rendering problems with FigureCanvasWxAgg on OSX #10174

@mattsbjorck

Description

@mattsbjorck

Bug report

Bug summary

Including FigureCanvasWxAgg in wx app with log scale axis causes issues with repainting the window, sometime the Figure is painted in the wrong place or another panel is painted over it.
Removing the log scale (using a linear scale) causes it to paint correctly. This work in older versions of wxpython(3.0.0) and python(2.7.6). issue appears on OSX.

Code for reproduction

"""Script to test and explore the issue with bad repainting of a the SplitterWindow."""
import wx

import matplotlib as mpl
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as Canvas


class Plot(wx.Panel):
    def __init__(self, parent, id=-1, dpi=None, **kwargs):
        wx.Panel.__init__(self, parent, id=id, **kwargs)
        self.figure = mpl.figure.Figure(dpi=dpi, figsize=(2, 2))
        self.canvas = Canvas(self, -1, self.figure)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.canvas, 1, wx.EXPAND)
        self.SetSizer(sizer)


class MainFrame(wx.Frame):
    def __init__(self, *args, **kwds):
        wx.Frame.__init__(self, *args, **kwds)

        self.ver_splitter = wx.SplitterWindow(self, -1, style=wx.SP_3D)
        self.hor_splitter = wx.SplitterWindow(self.ver_splitter, -1, style=wx.SP_3D)

        self.input_notebook = wx.Notebook(self.hor_splitter, -1, style=wx.NB_BOTTOM | wx.NO_BORDER)
        self.plot_notebook = wx.Notebook(self.hor_splitter, -1, style=wx.NB_BOTTOM | wx.NO_BORDER)

        self.panel_left = wx.Notebook(self.ver_splitter)

        self.plot_data = Plot(self.plot_notebook)
        self.plot_notebook.AddPage(self.plot_data, "Data")


        self.ver_splitter.SplitVertically(self.panel_left, self.hor_splitter)
        self.hor_splitter.SplitHorizontally(self.plot_notebook, self.input_notebook)

        self.Layout()

        axes = self.plot_data.figure.gca()
        axes.plot([1, 2, 3], [1, 10, 100.])
       # Comment out the line below to remove the problem.
        axes.set_yscale('log')

if __name__ == "__main__":
    app = wx.App(False)
    main_frame = MainFrame(None)
    main_frame.Show()
    app.MainLoop()

Actual outcome

See screenshot below. This is not static but appears sometimes upon resizing the window or the sizers. Sometimes the plot is plotted in the wrong place as well. The gray part of the plot is actually the panel located on the left painted on the wrong place.

issue1

Matplotlib version
Mac OSX 10.12.6
Python 3.6.1
wxpython 4.0.0b2 osx-cocoa (phoenix)
Matplotlib 2.1.1

Python installed from miniconda, wxpython with pip.

Any help or pointers that could help are welcome!

Matts Björck

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions