[Matplotlib-users] Colored bitmaps with MathTextParser
Hello, Is it possible to get colored bitmaps (instead of black ones) with the MathTextParser when it is used as shown in the mathtext_wx.py example ?? Thanks by advance for your help. Best regards, Cédrick FAURY -- ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Text not showing up when I save a figure as EPS
Hello, When I save the figure as EPS, no text shows up. The problem occurs with the example embedding_in_wx2.py and when I use MSWord to show the eps file. Is it a problem with MSWord ?? Thanks by advance. Cédrick -- The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] transData.transform on 'log' plot
Hello, When I try to use transData.transform on a log plot, an error occurs : ... File E:\Python26\lib\site-packages\matplotlib\transforms.py, line 1895, in transform self._a.transform(points)) File E:\Python26\lib\site-packages\matplotlib\transforms.py, line 1723, in transform x_points = x.transform(points[:, 0]) TypeError: tuple indices must be integers, not tuple Here is an example : #!/usr/bin/env python import matplotlib matplotlib.use('WXAgg') from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas from matplotlib.figure import Figure import wx class CanvasFrame(wx.Frame): def __init__(self): wx.Frame.__init__(self,None,-1, 'CanvasFrame',size=(550,350)) self.SetBackgroundColour(wx.NamedColor(WHITE)) self.figure = Figure() self.axes = self.figure.add_subplot(111) self.axes.set_xscale('log') p1 = (1,1) p2 = (2,2) _x1, _y1 = self.axes.transData.transform(p1) _x2, _y2 = self.axes.transData.transform(p2) _xy = [[_x1, _y1], [_x2, _y2]] xy = self.axes.transData.inverted().transform(_xy) self.axes.plot(xy) 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() class App(wx.App): def OnInit(self): frame = CanvasFrame() frame.Show(True) return True app = App(0) app.MainLoop() If I comment the line : self.axes.set_xscale('log'), it works fine. python 2.6.4 wxpython 2.8.10 mpl 0.99 Thanks by advance for your help. Cédrick -- Throughout its 18-year history, RSA Conference consistently attracts the world's best and brightest in the field, creating opportunities for Conference attendees to learn about information security's most important issues through interactions with peers, luminaries and emerging and established companies. http://p.sf.net/sfu/rsaconf-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] MathTextParser, maxdict ... Assertion failed!
Thank you very much !! With python 2.6... There is no error, no crash... Michael Droettboom a écrit : I don't think maxdict is the problem though it may be changing how the problem manifests itself. What is happening is that when maxdict is used, those C++ extension objects are deleted after the first 50 math expressions. When using a dict, they aren't deleted until closing the application, so it just delays the problem. All that said, I'm not sure as to the real cause of the error. I was able to reproduce it on Windows XP with: mpl 0.98.5, wx 2.8.10.6, python 2.5.4 however, the following seems to work: mpl 0.98.5, wx 2.8.10.6, python 2.6.3 Are you able to update to Python 2.6? That might be one solution to the problem. I have to say I'm completely stumped as to the root cause of this one. Mike On 10/17/2009 08:44 AM, Cédrick FAURY wrote: Hello, I restate the problem : With the attached script test_mathtext_wx.py : 50 functions (line 31) : the 50 bitmaps are generated correctly, by when I close the application an error appears in the console : Assertion failed: ob_refcnt == 0, file CXX\cxx_extensions.cxx, line 1128 This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. 250 functions : the window never appears and the crash occurs (same message) However, if in mathtext.py (mpl 0.98.5 win32 py2.5) line 2765 in MathTextParser, I put self._cache = dict() instead of self._cache = maxdict(50), the behavior of test_mathtext_wx.py is significantly different. 50 functions : error on console after closing the application (no difference here) 250 functions : NO CRASH (but error after closing the application) And now, my questions : Is this proof that maxdict is the cause of the problem ? Is there a known way to avoid the problem? Can someone tell me more about maxdict ? Hoping to have been quite clear, Cédrick -- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Log scale produces unreadable svg files
Hello, If I add self.axes.set_xscale('log') after the line 38 of the example file embedding_in_wx2.py, and if I save the figure as svg, it produces an unreadable file. Nor Firefox neither Inkscape can read it. Is there a solution ? Cédrick -- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] MathTextParser, maxdict ... Assertion failed!
Hello, I restate the problem : With the attached script test_mathtext_wx.py : 50 functions (line 31) : the 50 bitmaps are generated correctly, by when I close the application an error appears in the console : Assertion failed: ob_refcnt == 0, file CXX\cxx_extensions.cxx, line 1128 This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. 250 functions : the window never appears and the crash occurs (same message) However, if in mathtext.py (mpl 0.98.5 win32 py2.5) line 2765 in MathTextParser, I put self._cache = dict() instead of self._cache = maxdict(50), the behavior of test_mathtext_wx.py is significantly different. 50 functions : error on console after closing the application (no difference here) 250 functions : NO CRASH (but error after closing the application) And now, my questions : Is this proof that maxdict is the cause of the problem ? Is there a known way to avoid the problem? Can someone tell me more about maxdict ? Hoping to have been quite clear, Cédrick Demonstrates how to convert mathtext to a wx.Bitmap for display in various controls on wxPython. import matplotlib matplotlib.use(WxAgg) from numpy import arange, sin, pi, cos, log from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas from matplotlib.backends.backend_wx import NavigationToolbar2Wx from matplotlib.figure import Figure import wx IS_GTK = 'wxGTK' in wx.PlatformInfo IS_WIN = 'wxMSW' in wx.PlatformInfo IS_MAC = 'wxMac' in wx.PlatformInfo # This is where the magic happens. from matplotlib.mathtext import MathTextParser mathtext_parser = MathTextParser(Bitmap) def mathtext_to_wxbitmap(s): ftimage, depth = mathtext_parser.parse(s, 150) return wx.BitmapFromBufferRGBA( ftimage.get_width(), ftimage.get_height(), ftimage.as_rgba_str()) functions = [] for i in range(250): functions.append((r'$\frac{x}{%d}$' % i, lambda x: x)) class CanvasFrame(wx.Frame): def __init__(self, parent, title): wx.Frame.__init__(self, parent, -1, title, size=(550, 350)) self.SetBackgroundColour(wx.NamedColor(WHITE)) self.scroll = wx.ScrolledWindow(self, -1) self.scroll.SetScrollRate(20,20) self.sizer = wx.BoxSizer(wx.VERTICAL) for f in functions: self.sizer.Add(wx.StaticBitmap(self.scroll, -1, mathtext_to_wxbitmap(f[0]))) self.scroll.FitInside() self.scroll.SetSizer(self.sizer) class MyApp(wx.App): def OnInit(self): frame = CanvasFrame(None, wxPython mathtext demo app) self.SetTopWindow(frame) frame.Show(True) return True app = MyApp() app.MainLoop() -- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] How to setup zdata on Line3D ?
Hello, I can't find the way to change the zdata on a Line3D object. (mpl 99.1) I would like to use setp ... Thanks by advance Cédrick -- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] MathTextParser, maxdict ... Assertion failed!
Hello, I did an application that uses bitmaps constructed with MathTextParser as described in the example http://matplotlib.sourceforge.net/examples/user_interfaces/mathtext_wx.html (I work with Windows XP, python 2.5, Matplotlib 0.98.5 and wxPython 2.8.10.1) After making a lot of these bitmaps (from about 50 to 150...) the program crash as described in the thread [matplotlib-devel] Fontcache problem on windows http://www.mail-archive.com/matplotlib-de...@lists.sourceforge.net/msg02353.html. I spent hours on this problem ... and I found this : It seems to come from the maxdict(50) instance used by the MathTextParser as cache : if I replace it by a simple dict, my program works fine ... but the cache never stop to grow up ! Has anyone (among developpers ?) an idea for doing things better. Thanks by advance Cédrick PS : Please, be indulgent with my English ... -- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] MathTextParser, maxdict ... Assertion failed!
Thank you for responding so quickly !! I don't think these problems are related. One is a cache of math expression images, the other is a cache of fonts. I know ... and i found a lot of way to reproduce the same crash... I am unable to reproduce this on Matplotlib 0.98.5.3 on Linux (don't have a Windows box handy). Can you run the attached script (which is just a modification of mathtext_wx.py to generate 60 different math expressions, and let me know if that crashes for you? This script does'nt work (it causes a PyAssertion error : invalid stock id) But with this more simple attached script : For 50 bitmaps, the crash occurs after the window is closed (with the cross). For 250, the crash occurs before the apparition of the window In the Command prompt : Assertion failed: ob_refcnt == 0, file CXX\cxx_extensions.cxx, line 1128 This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. No more traceback ... Cédrick Demonstrates how to convert mathtext to a wx.Bitmap for display in various controls on wxPython. import matplotlib matplotlib.use(WxAgg) from numpy import arange, sin, pi, cos, log from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas from matplotlib.backends.backend_wx import NavigationToolbar2Wx from matplotlib.figure import Figure import wx IS_GTK = 'wxGTK' in wx.PlatformInfo IS_WIN = 'wxMSW' in wx.PlatformInfo IS_MAC = 'wxMac' in wx.PlatformInfo # This is where the magic happens. from matplotlib.mathtext import MathTextParser mathtext_parser = MathTextParser(Bitmap) def mathtext_to_wxbitmap(s): ftimage, depth = mathtext_parser.parse(s, 150) return wx.BitmapFromBufferRGBA( ftimage.get_width(), ftimage.get_height(), ftimage.as_rgba_str()) functions = [] for i in range(250): functions.append((r'$\frac{x}{%d}$' % i, lambda x: x)) class CanvasFrame(wx.Frame): def __init__(self, parent, title): wx.Frame.__init__(self, parent, -1, title, size=(550, 350)) self.SetBackgroundColour(wx.NamedColor(WHITE)) self.scroll = wx.ScrolledWindow(self, -1) self.scroll.SetScrollRate(20,20) self.sizer = wx.BoxSizer(wx.VERTICAL) for f in functions: self.sizer.Add(wx.StaticBitmap(self.scroll, -1, mathtext_to_wxbitmap(f[0]))) self.scroll.FitInside() self.scroll.SetSizer(self.sizer) class MyApp(wx.App): def OnInit(self): frame = CanvasFrame(None, wxPython mathtext demo app) self.SetTopWindow(frame) frame.Show(True) return True app = MyApp() app.MainLoop() -- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] MathTextParser, maxdict ... Assertion failed!
This script does'nt work (it causes a PyAssertion error : invalid stock id) If it's a PyAssertion error, it should have a traceback. Is there not one? No, this problem is not related with Matplotlib : the PyAssertion error occurs when creating the wx.Menu ... Cédrick -- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Printing in wx : a solution ?
Hello, Printing in wx (with printing_in_wx.py from mpl examples) doesn't work on all pc (windows) I have tested. A crash occur as described in the thread Printing in wx http://sourceforge.net/mailarchive/message.php?msg_id=00de01c9dec9%240fed4310%241022a8c0%40ipkgatersleben.de The only solution I found is to comment the line 2155 in backend_wx.py (self.canvas.figure.draw(renderer)) The inconvenience is that the scale of the figure change on screen (during a short moment). I hope it could help someone ... Cédrick -- Come build with us! The BlackBerryreg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9#45;12, 2009. Register now#33; http://p.sf.net/sfu/devconf___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Unknown Path Error
Hi, I have the same problem as Andrew Kelly I did the example code below (from coords_demo.py) to reproduce the bug : #!/usr/bin/env python An example of how to interact with the plotting canvas by connecting to move and click events import sys from pylab import * t = arange(0.0, 1.0, 0.01) s = sin(2*pi*t) ax = subplot(111) ax.set_xscale('log') #ax.plot(t,s) ax.axhline(0.5, 0, 1) def on_move(event): # get the x and y pixel coords x, y = event.x, event.y if event.inaxes: ax = event.inaxes # the axes instance print 'data coords', event.xdata, event.ydata lst = ax.hitlist(event) def on_click(event): # get the x and y coords, flip y from top to bottom x, y = event.x, event.y if event.button==1: if event.inaxes is not None: print 'data coords', event.xdata, event.ydata binding_id = connect('motion_notify_event', on_move) connect('button_press_event', on_click) if test_disconnect in sys.argv: print disconnecting console coordinate printout... disconnect(binding_id) show() Regards, Cédrick -- Come build with us! The BlackBerryreg; Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9#45;12, 2009. Register now#33; http://p.sf.net/sfu/devconf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users