Re: [Matplotlib-users] X Window System error
On 2012/10/01 7:28 PM, Mic wrote: > Hi, > > I have got the following error with the following code: > /$ python mpl.py/ > /Traceback (most recent call last):/ > / File > "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_gtk.py", > line 398, in expose_event/ > /self._render_figure(self._pixmap, w, h)/ > / File > "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_gtkagg.py", > line 75, in _render_figure/ > /FigureCanvasAgg.draw(self)/ > / File > "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.py", > line 416, in draw/ > /self.renderer = self.get_renderer()/ > / File > "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.py", > line 435, in get_renderer/ > /self.renderer = RendererAgg(w, h, self.figure.dpi)/ > / File > "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.py", > line 72, in __init__/ > /self._renderer = _RendererAgg(int(width), int(height), dpi, > debug=False)/ > /ValueError: width and height must each be below 32768/ > /The program 'mpl.py' received an X Window System error./ > /This probably reflects a bug in the program./ > /The error was 'BadAlloc (insufficient resources for operation)'./ > / (Details: serial 486 error_code 11 request_code 53 minor_code 0)/ > / (Note to programmers: normally, X errors are reported asynchronously;/ > / that is, you will receive the error a while after causing it./ > / To debug your program, run it with the --sync command line/ > / option to change this behavior. You can then get a meaningful/ > / backtrace from your debugger if you break on the gdk_x_error() > function.)/ > > With the following code: > /import random / > /import matplotlib.pyplot as plt / > // > /coverages = [random.randint(1,10)*2] * 4605 / > /contig_names = ['AAB0008r'] * len(coverages) / > /# Set the figure size / > /#fig = plt.figure(1, [20, 2]) / > /fig = plt.figure(figsize=(int(len(coverages)*0.1), 4)) / > // > /ax = fig.add_subplot(111) / > // > /# Set the x-axis limit / > /#ax.set_xlim(-1,100) / > /ax.set_xlim(0,len(coverages)) / > /#ax.set_ylim(0,3) / > /ax.yaxis.grid(True, linestyle='-', which='major', color='grey', > alpha=0.5) / > // > /ind = range(len(coverages)) / > /rects = ax.bar(ind, coverages, width=0.1, align='center', > color='thistle') / > /ax.set_xticks(ind) / > /#ax.set_xticklabels(contig_names)/ > /#ax.tick_params(axis='both', which='major', labelsize=10)/ > /#ax.tick_params(axis='both', which='minor', labelsize=8)/ > / > / > / > / > /#function to auto-rotate the x axis labels/ > /fig.autofmt_xdate()/ > /plt.setp(ax.get_xticklabels(), fontsize=8, rotation='vertical')/ > /plt.show()/ > > How is it possible to get big charts? It looks like you are trying to make a figure that is 460 inches by 4 inches. How do you expect to display or print it? I think displaying it is out of the question, so you would need to use a non-interactive backend. I don't know whether ps or pdf can handle those sorts of dimensions. Eric > > Thank you in advance. > > > > -- > Don't let slow site performance ruin your business. Deploy New Relic APM > Deploy New Relic app performance management and know exactly > what is happening inside your Ruby, Python, PHP, Java, and .NET app > Try New Relic at no cost today and get our sweet Data Nerd shirt too! > http://p.sf.net/sfu/newrelic-dev2dev > > > > ___ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Qt4/PySide memory leak
On 9/24/2012 5:50 PM, Christoph Gohlke wrote: On 9/24/2012 3:32 PM, David Honcik wrote: I've run into a large memory leak using Matplotlib with PySide and the Qt4 back end. I'm using : Python 3.2 Numpy 1.6.2 Pyside 1.1.1 (qt474) Matplotlib 1.2 (first the Capetown Group port to Python 3, then 1.2 RC2) on Windows XP 32 bit I've tried using the Python 2.7 branch of all of the above and don't see the problem. I don't see the problem with the Tk back end. I don't see the problem with the Qt4 back end and PyQt4. Only with the above mentioned versions and using the Qt4 back end with PySide. The following script will reproduce the problem : import matplotlib matplotlib.use('Qt4Agg') matplotlib.rcParams['backend.qt4']='PySide' import pylab arrayX = [] arrayY = [] for nIndex in range(0, 100): arrayX.append(nIndex) arrayY.append(nIndex) Figure = matplotlib.pyplot.figure(1) Axes = Figure.add_axes([ 0.05, 0.05, 0.95, 0.95]) Axes.plot(arrayX, arrayY, color = "blue", marker = "o", markersize = 5.0) Axes.set_xlim(arrayX[0], arrayX[len(arrayX) - 1]) Axes.set_ylim(arrayY[0], arrayY[len(arrayY) - 1]) matplotlib.pyplot.show() I run the above, grab the lower right sizing handle on the plot window and start resizing the window. Watching the python process in task manager, each resize leaks a noticeable amount of memory. A few minutes of this will get process memory up to ~2.5 GB. At that point it crashes. I'm new here, am I in the right place? I can reproduce this exactly, also with pyside 1.1.2 and an empty plot. Looks like QtGui.QImage is leaking. import matplotlib matplotlib.use('Qt4Agg') matplotlib.rcParams['backend.qt4']='PySide' from matplotlib import pyplot pyplot.plot() pyplot.show() -- Christoph As a workaround, until PySide is fixed, use the attached patch, which forcibly decreases the reference count of the string buffer after use. Christoph diff --git a/lib/matplotlib/backends/backend_qt4agg.py b/lib/matplotlib/backends/backend_qt4agg.py index 0701781..408f3ce 100644 --- a/lib/matplotlib/backends/backend_qt4agg.py +++ b/lib/matplotlib/backends/backend_qt4agg.py @@ -4,6 +4,7 @@ Render to qt from agg from __future__ import division, print_function import os, sys +import ctypes import matplotlib from matplotlib.figure import Figure @@ -15,6 +16,10 @@ from backend_qt4 import QtCore, QtGui, FigureManagerQT, FigureCanvasQT,\ DEBUG = False +decref = ctypes.pythonapi.Py_DecRef +decref.argtypes = [ctypes.py_object] +decref.restype = None + def new_figure_manager( num, *args, **kwargs ): """ @@ -95,6 +100,8 @@ class FigureCanvasQTAgg( FigureCanvasQT, FigureCanvasAgg ): else: stringBuffer = self.renderer._renderer.tostring_argb() +refcnt = sys.getrefcount(stringBuffer) + qImage = QtGui.QImage(stringBuffer, self.renderer.width, self.renderer.height, QtGui.QImage.Format_ARGB32) @@ -106,6 +113,11 @@ class FigureCanvasQTAgg( FigureCanvasQT, FigureCanvasAgg ): p.setPen( QtGui.QPen( QtCore.Qt.black, 1, QtCore.Qt.DotLine ) ) p.drawRect( self.rect[0], self.rect[1], self.rect[2], self.rect[3] ) p.end() + +del qImage +if refcnt != sys.getrefcount(stringBuffer): +# Fix a memory leak in PySide on Python 3 +decref(stringBuffer) else: bbox = self.blitbox l, b, r, t = bbox.extents -- Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] static linking
Figured it out. The real trick is to set the PKG_CONFIG_PATH properly. No need for LD_LIBRARY_PATH On Sun, Sep 30, 2012 at 9:52 AM, Rita wrote: > Nelly, > I would like to compile libpng into matplotlib if possible, ie static. > Seems like thats not possible and I would like to would LD_LIBRARY_PATH as > much as possible. I much prefer -Wl, rpath or LD_PRELOAD. > > Jouni, > for the pkg-config can I use the one with my OS, /usr/bin/pkg-config? and > also libpng comes with its own variation of pkg-config (not named that). > How can I include that? do I set PKG_CONFIG_PATH ? > > > > > > On Sun, Sep 30, 2012 at 3:30 AM, Nelle Varoquaux < > nelle.varoqu...@gmail.com> wrote: > >> >> On 30 Sep 2012 06:11, "Jouni K. Seppänen" wrote: >> > >> > Rita writes: >> > >> > > i have a micro distribution setup. I am building python, numpy, scipy >> from >> > > scratch. I am building matplotlib from scratch also. >> > > >> > > I am doing a simple, /apps/bin/python setup.py build. >> > > >> > > I also compiled libpng and cairo in a location. >> >> When you build a shared library yourself, you always need to set the >> variable LD_LIBRARY_PATH. This is independant from the compilation. At >> runtime, the program merely tries to load the library if it has not been >> loaded previously. >> >> Usually, to avoid setting manually the path to the library, one adds this >> to its bashrc/zshrc. >> >> I hope this helps. >> Cheers, >> N. >> >> > >> > Have you set up pkg-config for your build of libpng? If you can't do >> > that for some reason, you can edit basedirlist in setup.cfg. >> > >> > -- >> > Jouni K. Seppänen >> > http://www.iki.fi/jks >> > >> > >> > >> -- >> > Everyone hates slow websites. So do we. >> > Make your web apps faster with AppDynamics >> > Download AppDynamics Lite for free today: >> > http://ad.doubleclick.net/clk;258768047;13503038;j? >> > http://info.appdynamics.com/FreeJavaPerformanceDownload.html >> > ___ >> > Matplotlib-users mailing list >> > Matplotlib-users@lists.sourceforge.net >> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> >> >> -- >> Everyone hates slow websites. So do we. >> Make your web apps faster with AppDynamics >> Download AppDynamics Lite for free today: >> http://ad.doubleclick.net/clk;258768047;13503038;j? >> http://info.appdynamics.com/FreeJavaPerformanceDownload.html >> ___ >> Matplotlib-users mailing list >> Matplotlib-users@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> >> > > > -- > --- Get your facts first, then you can distort them as you please.-- > -- --- Get your facts first, then you can distort them as you please.-- -- Got visibility? Most devs has no idea what their production app looks like. Find out how fast your code is with AppDynamics Lite. http://ad.doubleclick.net/clk;262219671;13503038;y? http://info.appdynamics.com/FreeJavaPerformanceDownload.html___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] imlim in ax.imshow
Hi! I see that the function ax.imshow takes the parameter 'imlim' but in the source (status: EPD 7.3-2) it is not being used? So what is it for? Best regards, Michael -- Got visibility? Most devs has no idea what their production app looks like. Find out how fast your code is with AppDynamics Lite. http://ad.doubleclick.net/clk;262219671;13503038;y? http://info.appdynamics.com/FreeJavaPerformanceDownload.html ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users