Skip to content

WXAgg backend not rendering nicely on retina #7720

@LtMerlin

Description

@LtMerlin

When embedding a matplotlib plot in a WX.Panel, the figure_canvas is not rendered nicely on a retina display. Increasing the dpi of the figure does not help (it only alters the figure size).

Matplotlib version: 2.0.0rc2 (installed with pip) (same behaviour as with 1.5.3)
Python version: 2.7.13 (installed with homebrew)
Platform: OSX (macOS Sierra)

Plotting using standard MacOSX backend (no embedding):

import matplotlib
matplotlib.use("MacOSX") #put here explicitly for reference

from numpy import arange, sin, pi
import matplotlib.pyplot as plt

figure = plt.figure()
axes = figure.add_subplot(111)
t = arange(0.0, 3.0, 0.01)
s = sin(2 * pi * t)
axes.plot(t, s)

plt.show()

screenshot_using_macosx_backend

Plotting using the WXAgg backend (embed inside WX.Panel):

from numpy import arange, sin, pi
import matplotlib
matplotlib.use('WXAgg')

from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
from matplotlib.backends.backend_wx import NavigationToolbar2Wx
from matplotlib.figure import Figure

import wx

class CanvasPanel(wx.Panel):
    def __init__(self, parent):
        wx.Panel.__init__(self, parent)
        self.figure = Figure()
        self.axes = self.figure.add_subplot(111)
        self.canvas = FigureCanvas(self, -1, self.figure)
        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW)
        self.SetSizer(self.sizer)
        self.Fit()

    def draw(self):
        t = arange(0.0, 3.0, 0.01)
        s = sin(2 * pi * t)
        self.axes.plot(t, s)

if __name__ == "__main__":
    app = wx.App()
    fr = wx.Frame(None, title='test')
    panel = CanvasPanel(fr)
    panel.draw()
    fr.Show()
    app.MainLoop()

screenshot_wx_embed

Any workarounds or tips?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy