Hello, Kindly guide me using a simple step-by-step approach on embeding a matplotlib figure in a wxPython classic GUI. The matplotlib documentation on WXAgg is difficult for me to uderstand. And I coldn't find a simple tutorial online. Hope to hear from you soon. Thanks for your time in advance. My system configurations: Windows 7, Python 2.7.12, and wxPython 3.0-msw classic # ========= MatPlotLib Figure Appear in Blue part while controls at right and bottom ================# import wx import wx.xrc
class MyFrame1 ( wx.Frame ): def __init__( self, parent ): wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = wx.EmptyString, pos = wx.DefaultPosition, size = wx.Size( 700,500 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL ) self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize ) bSizer1 = wx.BoxSizer( wx.HORIZONTAL ) bSizer5 = wx.BoxSizer( wx.VERTICAL ) bSizer6 = wx.BoxSizer( wx.VERTICAL ) self.m_staticText3 = wx.StaticText( self, wx.ID_ANY, u"MatPlotLib Graph Here\n\n?\n\n?", wx.DefaultPosition, wx.DefaultSize, wx.ALIGN_CENTRE ) self.m_staticText3.Wrap( -1 ) self.m_staticText3.SetFont( wx.Font( 20, 70, 90, 90, False, wx.EmptyString ) ) self.m_staticText3.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_HIGHLIGHT ) ) bSizer6.Add( self.m_staticText3, 1, wx.ALL|wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL, 5 ) bSizer5.Add( bSizer6, 1, wx.EXPAND, 5 ) bSizer7 = wx.BoxSizer( wx.VERTICAL ) self.m_staticText1 = wx.StaticText( self, wx.ID_ANY, u"Controls Here", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText1.Wrap( -1 ) self.m_staticText1.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_BTNSHADOW ) ) bSizer7.Add( self.m_staticText1, 0, wx.ALL|wx.EXPAND, 5 ) bSizer5.Add( bSizer7, 0, wx.EXPAND, 5 ) bSizer1.Add( bSizer5, 1, wx.EXPAND, 5 ) bSizer8 = wx.BoxSizer( wx.VERTICAL ) self.m_staticText2 = wx.StaticText( self, wx.ID_ANY, u"Controls Here", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText2.Wrap( -1 ) self.m_staticText2.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_BTNSHADOW ) ) bSizer8.Add( self.m_staticText2, 1, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 5 ) bSizer1.Add( bSizer8, 0, wx.EXPAND, 5 ) self.SetSizer( bSizer1 ) self.Layout() self.Centre( wx.BOTH ) def __del__( self ): pass app = wx.App() frame = MyFrame1(None).Show() app.MainLoop()
-- You received this message because you are subscribed to the Google Groups "wxPython-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-user...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Hello, Kindly guide me using a simple step-by-step approach on embeding a matplotlib figure in a wxPython classic GUI. The matplotlib documentation on WXAgg is difficult for me to uderstand. And I coldn't find a simple tutorial online. Hope to hear from you soon. Thanks for your time in advance. My system configurations: Windows 7, Python 2.7.12, and wxPython 3.0-msw classic
Dietmar Schwertberger wrote:
> Unfortunately, matplotlib has no good way to export plots into Microsoft Office, so I'm
> always using my own wx based plot library...
This is not completely accurate, though it might be that the standard pylab.plot resulting Frame does not have a good way to export plots.
With wxmplot, Ctrl-C (or Apple-C on Mac OS X) from the PlotPanel copies the image of the panel to the system Clipboard which can then be pasted into many Windows/Mac apps (and certainly Office apps) with Ctrl-V/Apple-V. In addition, saving the image (Ctrl-S/Apple-S) to a PNG file gives a publication quality image (I have published several of these plots directly from wxmplot/matplotlib) that can easily be included into many apps, including Office apps.
On 24.08.2016 16:06, Matt Newville wrote:
Well, that's what I mean with "no good way", as PNG ist not an option for me when I want to create PDFs.Dietmar Schwertberger wrote:
> Unfortunately, matplotlib has no good way to export plots into Microsoft Office, so I'm
> always using my own wx based plot library...
This is not completely accurate, though it might be that the standard pylab.plot resulting Frame does not have a good way to export plots.
With wxmplot, Ctrl-C (or Apple-C on Mac OS X) from the PlotPanel copies the image of the panel to the system Clipboard which can then be pasted into many Windows/Mac apps (and certainly Office apps) with Ctrl-V/Apple-V. In addition, saving the image (Ctrl-S/Apple-S) to a PNG file gives a publication quality image (I have published several of these plots directly from wxmplot/matplotlib) that can easily be included into many apps, including Office apps.
For PDFs I want to have vector graphics. Images are either ugly or create large files. Also EMF/WMF plots have the advantages that they can be post-processed more easily when you want to shift or add something.
There used to be a EMF backend, but this is no longer available.
Unfortunately, the wx matplotlib backend uses matplotlib to render an image and then paint it to the screen.
Any volunteers to implement a wx vector backend? I would have considered doing this, but currently I'm busy in re-working wxGlade...
FWIW, I find the PNGs from matplotlib to be very high quality, and am very happy they can readily render TeX strings for mathematical symbols. I do tend to make high density or large images, but I wouldn't call them large files (rarely > 0.5MB). I have no trouble embedding these in MS Office docs, latex-generaed PDFs, or web pages. But, like you say, they are definitely images and the plot components are not easily manipulated later.
Matplotlib can also save to SVG, which is a vector graphics format and so might be closer to what you want. I believe these are not immediately used by MS Office, but can be converted to EMF or WMF, though I do not know any details.
Unfortunately, Microsoft still does not support SVG in Office. This will probably never change, even though Internet Explorer can view SVG.Would SVG work?