Re: [Matplotlib-users] plot() not using alpha value from RGBA tuple
On 07/25/2011 08:21 AM, Ben Breslauer wrote: I think that I have found the problem here. Line2D.draw() (and I presume other Artist subclasses) calls gc.set_foreground(self._color) ... gc.set_alpha(self._alpha) self._color is defined by the color kwarg, whether it be a hex value, 3-tuple, 4-tuple, or something else. self._alpha is defined by the alpha kwarg, but if the alpha kwarg is None, it is not overwritten with color[3]. Therefore, using color=(R,G,B,A) does not set alpha correctly. I'm not sure the best (i.e. most matplotlib-like) way to change this so that the A value gets used iff alpha is None, but I've attached a patch that does it one way (diff'ed against the github master, commit 67b1cd650f574f9c53ce). I know the patch is less than ideal, as it adds kwarg-specific handling into a place where none had previously been done, and it's also in a for loop. Maybe it would be better to do the checking along with the scalex and scaley pops? Alpha handling is a real can of worms; it has gotten better, but as you note, there are still problems. Unfortunately, I don't think your proposed solution will work in general, because self._color could be a 4-letter string, like gray, in which case alpha would be set to y, and that would not be good at all. I suspect the right place to solve the problem is down in the GraphicsContext--although I thought I had already straightened that out some time ago. As Ben notes, you should file a bug report. Given that the handling of colors and alpha is inherently tricky (and backend-dependent--ps doesn't support alpha at all), solving the problem well is going to take a bit of time and care, most likely--and testing to make sure that a fix in one place doesn't cause a bug in another. I think we should leave it alone until after the next release. Eric Separately, I noticed that backend_bases.GraphicsContextBase.set_foreground claims to only expect an RGB definition, and not an RGBA definition. As such, I think that it should call self._rgb = colors.colorConverter.to_rgb(fg) instead of self._rgb = colors.colorConverter.to_rgba(fg) since that will make self._rgb a 3-tuple instead of a 4-tuple. Ben On Sat, Jul 23, 2011 at 3:13 PM, Ben Breslauer bbresla...@gmail.com mailto:bbresla...@gmail.com wrote: Hi, I'm trying to fade some data, using alpha values, that I am plotting with Axes.plot(). I can recreate this problem with 1 line of pylab.plot. If I use pylab.plot([1,2,3],[1,4,9], color=(1,0,0,.2), linewidth=7) then I get the equivalent of pylab.plot([1,2,3],[1,4,9], color=(1,0,0), linewidth=7) i.e. it does not use the alpha value. However, if instead I use pylab.plot([1,2,3],[1,4,9], color=(1,0,0), linewidth=7, alpha=.2) then the line is faded out appropriately. The plot documentation indicates that RGBA tuples should be valid, so I'm wondering if this is a bug. Maybe alpha is defaulting to 1 or None and then not being overwritten if color is a 4-tuple? I'm using Arch Linux with kernel 2.6.39, matplotlib 1.0.1 from the Arch repo, and the Qt4 backend. My installed Qt version is 4.7.3, and I am using KDE 4.6.5. Below is verbose-debug output. Thanks for any help! Ben $HOME=/home/ben CONFIGDIR=/home/ben/.matplotlib matplotlib data path /usr/lib/python2.7/site-packages/matplotlib/mpl-data loaded rc file /usr/lib/python2.7/site-packages/matplotlib/mpl-data/matplotlibrc matplotlib version 1.0.1 verbose.level debug interactive is False units is False platform is linux2 loaded modules: ['heapq', 'numpy.core.info http://numpy.core.info', 'distutils', 'numpy.lib.format', 'functools', 'pylab', '_bisect', 'subprocess', 'sysconfig', 'gc', 'matplotlib.tempfile', 'distutils.sysconfig', 'ctypes._endian', 'encodings.encodings', 'pyparsing', 'matplotlib.colors', 'numpy.core.numerictypes', 'numpy.testing.sys', 'numpy.lib.__future__', 'numpy.fft.types', 'numpy.ma.cPickle', 'struct', 'numpy.matrixlib.defmatrix', 'numpy.random.info http://numpy.random.info', 'tempfile', 'numpy.compat.types', 'pprint', 'numpy.linalg', 'matplotlib.threading', 'numpy.core.machar', 'numpy.testing.types', 'numpy.testing', 'collections', 'numpy.polynomial.sys', 'unittest.sys', 'numpy.core.umath', 'unittest.main', 'distutils.types', 'numpy.testing.operator', 'numpy.core.scalarmath', 'numpy.ma.sys', 'zipimport', 'string', 'matplotlib.subprocess', 'numpy.testing.os', 'unittest.functools', 'numpy.lib.arraysetops', 'numpy.testing.unittest', 'numpy.lib.math', 'encodings.utf_8', 'matplotlib.__future__', 'unittest.types', 'unittest.util', 'numpy.testing.re http://numpy.testing.re', 'numpy.version', 'numpy.lib.re http://numpy.lib.re', 'distutils.re http://distutils.re', 'numpy.matrixlib.sys', 'ctypes.os',
[Matplotlib-users] How to set the data for an existing pcolormesh image?
Hello, for a interactive gui program i want to change the shown data without changing the rest of the figure. For normal plots, there is a set_xdata/set_ydata methods. For QuadMesh, there is a set_array method, which i don't get to work. Thanks, Till -- uberSVN's rich system and user administration capabilities and model configuration take the hassle out of deploying and managing Subversion and the tools developers use with it. Learn more about uberSVN and get a free download at: http://p.sf.net/sfu/wandisco-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Error with PDF output with usetex
Hi Jeff, I am able to run the tex_demo.py with no problems and I can create output files using the Agg backend. When I try to use the PDF backend, however, I get an error which stems from dviread.py (pasted below). Any thoughts on what could be going wrong? Thanks! Jeff Hi Jeff, How did you install matplotlib? From source yourself? No, I'm using the Enthought Python Distribution (EPD64). And when you installed matplotlib, did it see that you had dvipng installed? FYI, you can do which dvipng to return the path where dvipng lives (if it is in your path already) or you can do locate dvipng to do a search for the binary if it isn't already in your path. P.S. You forgot to reply-all so everyone can see your response. $ which dvipng /usr/texbin/dvipng I don't remember any complaints while running the EPD installer. Would there be a way to check this? Is the problem definitely related to an inability to find dvipng, or could there be other possibilities? Thanks, Jeff I had a similar problem. I don't think it's an inability to find dvipng, I think it's that it couldn't find dvipng when matplotlib was built. When matplotlib builds there'll be a section of text sent to stdout under the heading of 'OPTIONAL DEPENDENCIES', there it will tell you whether it found dvipng when it was building. Are you able to find this? If not, are there install logs saved somewhere after you installed matplotlib? Damon McDougall d.mcdoug...@warwick.ac.uk http://damon.is-a-geek.com B2.39 Mathematics Institute Coventry West Midlands CV4 7AL -- uberSVN's rich system and user administration capabilities and model configuration take the hassle out of deploying and managing Subversion and the tools developers use with it. Learn more about uberSVN and get a free download at: http://p.sf.net/sfu/wandisco-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] plot() not using alpha value from RGBA tuple
2011/8/16 Eric Firing efir...@hawaii.edu: On 07/25/2011 08:21 AM, Ben Breslauer wrote: I think that I have found the problem here. Line2D.draw() (and I presume other Artist subclasses) calls gc.set_foreground(self._color) ... gc.set_alpha(self._alpha) self._color is defined by the color kwarg, whether it be a hex value, 3-tuple, 4-tuple, or something else. self._alpha is defined by the alpha kwarg, but if the alpha kwarg is None, it is not overwritten with color[3]. Therefore, using color=(R,G,B,A) does not set alpha correctly. I'm not sure the best (i.e. most matplotlib-like) way to change this so that the A value gets used iff alpha is None, but I've attached a patch that does it one way (diff'ed against the github master, commit 67b1cd650f574f9c53ce). I know the patch is less than ideal, as it adds kwarg-specific handling into a place where none had previously been done, and it's also in a for loop. Maybe it would be better to do the checking along with the scalex and scaley pops? Alpha handling is a real can of worms; it has gotten better, but as you note, there are still problems. Unfortunately, I don't think your proposed solution will work in general, because self._color could be a 4-letter string, like gray, in which case alpha would be set to y, and that would not be good at all. I suspect the right place to solve the problem is down in the GraphicsContext--although I thought I had already straightened that out some time ago. ... Eric Separately, I noticed that backend_bases.GraphicsContextBase.set_foreground claims to only expect an RGB definition, and not an RGBA definition. As such, I think that it should call self._rgb = colors.colorConverter.to_rgb(fg) instead of self._rgb = colors.colorConverter.to_rgba(fg) since that will make self._rgb a 3-tuple instead of a 4-tuple. Ben ... Just a remark for this recent proposed patch, as I unfortunately don't know the implications for the whole codebase. I believe, that the condition added in the patch if len(line._color) == 4 and line._alpha == None: could be adjusted to e.g.: if isinstance(line._color, tuple) and len(line._color) == 4 and line._alpha == None If the alpha value can be set in the color-tuple (for #RRGGBBAA some parsing would be needed, if it is accepted). Possibly the _alpha should be replace with tha alpha value of the colour passed this way like http://matplotlib.sourceforge.net/api/colors_api.html#matplotlib.colors.ColorConverter.to_rgba If arg is an RGBA sequence and alpha is not None, alpha will replace the original A. But as has been suggested already, it might be better adressed in some more general way, than in this single function. regards, vbr -- uberSVN's rich system and user administration capabilities and model configuration take the hassle out of deploying and managing Subversion and the tools developers use with it. Learn more about uberSVN and get a free download at: http://p.sf.net/sfu/wandisco-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] finding the y coordinate at a particular x coordinate
Is there some way to determine the corresponding y coordinate of a shape (the edge of a circle for example) given an x coordinate of that shape? I know that for a circle there would be to 2 coordinates for each x coordinate, but I'm not actually plotting a whole circle, only a quarter of a circle. Which brings me to me 2nd quest of how you plot a quarter of a circle with radius of length of 1 onto an a canvas. -- View this message in context: http://old.nabble.com/finding-the-y-coordinate-at-a-particular-x-coordinate-tp32268951p32268951.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- uberSVN's rich system and user administration capabilities and model configuration take the hassle out of deploying and managing Subversion and the tools developers use with it. Learn more about uberSVN and get a free download at: http://p.sf.net/sfu/wandisco-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] How to get correct xtick labels with zooming and panning
Hi, If I create a bar graph inside a FigureCanvas, how do I get the correct x tick labels to display when someone does a zoom with the NavigationToolbar? For example, lets say I've got the below code: self.axes.set_xticks = range(len(vals)) self.axes.set_xticklabels(xLabels) self.axes.bar( left=range(len(vals)), height=map(float, vals), width=.2, align='center', alpha=0.44, picker=5) If the number of values is very large, then matplotlib seems to select only a few x labels to display (selecting far left and right, and some in the middle), but it's choosing the first ones in the specified label array, instead of indexing into it. I've tried setting the tick labels, based on the ticks it's selected, (setting labels based on the ticks after the bar has been created) and that seems to work on the initial load, but then if someone zooms into a particular part, it doesn't update the labels to the correct range . It's almost like I would need a callback to reset the labels . Ideas? Cheers, Lars smime.p7s Description: S/MIME cryptographic signature -- uberSVN's rich system and user administration capabilities and model configuration take the hassle out of deploying and managing Subversion and the tools developers use with it. Learn more about uberSVN and get a free download at: http://p.sf.net/sfu/wandisco-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] OS X 10.6.8 macports python2.6 64bit , Installing matplotlib fails.
I eventually got it to mostly work using: ³sudo port install py26-matplotlib @1.0.1 +gtk2² It doesn't match the correct egg format it seems, but it does work. On 8/10/11 11:01 AM, David Just just.da...@mayo.edu wrote: Hello, I¹ve been trying to install matplotlib correctly for the past couple of days. I¹m using a macports python2.6 built with +universal on. If I install with the the downloadable .egg file I end up with a message that states that _path.so has problems. (built for 32bit I guess) ImportError: dlopen(/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2 .6/site-packages/matplotlib-1.0.1_r0-py2.6.egg/matplotlib/_path.so, 2): no suitable image found. Did find: /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site -packages/matplotlib-1.0.1_r0-py2.6.egg/matplotlib/_path.so: no matching architecture in universal wrapper If I install with easy_install-2.6 matplotlib from source I get the following: Best match: matplotlib 0.91.1 src/_image.cpp:952: error: png_infopp_NULL¹ was not declared in this scope error: Setup script exited with error: command '/usr/bin/gcc-4.2' failed with exit status 1 If I install with port install matplotlib it fails because the install in not the correct path structure in the site-packages folder. I¹ve tried searching the web and have found some indications that I need to install 32bit python 2.6 but cannot find how to do that, and all of my production machinese have 64bit python installed on them. Any help at this point would be appreciated. Thanks. -- uberSVN's rich system and user administration capabilities and model configuration take the hassle out of deploying and managing Subversion and the tools developers use with it. Learn more about uberSVN and get a free download at: http://p.sf.net/sfu/wandisco-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] first steps with matplotlib
Hello, I begin with matplotlib and I draw volume is a 3D view. It runs acoorectly but some behavior are not understood. Here is my source code: fig = plt.figure() ax = Axes3D(fig) print long =,self.onevolume['long'] print lat =,self.onevolume['lat'] print upper =,self.onevolume['upper'] print lower =,self.onevolume['lower'] ax.plot(self.onevolume['long'],self.onevolume['lat'],self.onevolume['upper']) ax.plot(self.onevolume['long'],self.onevolume['lat'],self.onevolume['lower']) for i in range(len(self.onevolume)): ax.plot([self.onevolume['long'][i],self.onevolume['long'][i]], [self.onevolume['lat'][i],self.onevolume['lat'][i]], [self.onevolume['lower'][i],self.onevolume['upper'][i]]) ax.set_xlabel('Longitude (deg)') ax.set_title('Volumic definition of ' + volume) print axis=,ax.axis() canvas = FigureCanvas(fig) # a gtk.DrawingArea Here is the trace on my terminal: long = [-5.1384 -4.04805565 -4.05249977 -3.75972223 -3.9277 -4.066 -4.901 -5.1384] lat = [-49.7298 -49.4030571 -49.3955574 -49.4375 -50.34027863 -50.3206 -49.7641 -49.7298] upper = [999 999 999 999 999 999 999 999] lower = [245 245 245 245 245 245 245 245] axis= (-0.095001, 0.089997, -0.095001, 0.089997) Then I dont'understand the results given by function axis() regarding the input values. Finally, label is not written on x axis, why ? Here is my figure: http://old.nabble.com/file/p32231816/volume.jpeg Than you for all suggestions -- View this message in context: http://old.nabble.com/first-steps-with-matplotlib-tp32231816p32231816.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- uberSVN's rich system and user administration capabilities and model configuration take the hassle out of deploying and managing Subversion and the tools developers use with it. Learn more about uberSVN and get a free download at: http://p.sf.net/sfu/wandisco-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Best way to cycle through numpy images using scroll?
I have an array of images stored as an array of numpy arrays. I need to be able to efficiently scroll through that set of images. My first attempt at doing this goes something like this: --init-- self.ax = pyplot.imshow(imgdta[0], interpolation='spline36', cmap=cm.gray, picker=True) # draw the plot @UndefinedVariable pyplot.axes().set_axis_off() self.fig = self.ax.get_figure() self.canvas = FigureCanvasGTKAgg(self.fig) --onscroll-- self.ax.set_array(imdta[n]) # 0 n num_images self.canvas.draw() This method of changing the image data does not seem to be very preferment. It takes ~.25 seconds to go from one image to the next. Can anybody suggest a faster way? This also ends up in a canvas that¹s much larger than I need, is there a better way to define my view area? Thank you, Dave. -- uberSVN's rich system and user administration capabilities and model configuration take the hassle out of deploying and managing Subversion and the tools developers use with it. Learn more about uberSVN and get a free download at: http://p.sf.net/sfu/wandisco-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] OS X 10.6.8 macports python2.6 64bit , Installing matplotlib fails.
Hello, I¹ve been trying to install matplotlib correctly for the past couple of days. I¹m using a macports python2.6 built with +universal on. If I install with the the downloadable .egg file I end up with a message that states that _path.so has problems. (built for 32bit I guess) ImportError: dlopen(/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/pytho n2.6/site-packages/matplotlib-1.0.1_r0-py2.6.egg/matplotlib/_path.so, 2): no suitable image found. Did find: /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/si te-packages/matplotlib-1.0.1_r0-py2.6.egg/matplotlib/_path.so: no matching architecture in universal wrapper If I install with easy_install-2.6 matplotlib from source I get the following: Best match: matplotlib 0.91.1 src/_image.cpp:952: error: png_infopp_NULL¹ was not declared in this scope error: Setup script exited with error: command '/usr/bin/gcc-4.2' failed with exit status 1 If I install with port install matplotlib it fails because the install in not the correct path structure in the site-packages folder. I¹ve tried searching the web and have found some indications that I need to install 32bit python 2.6 but cannot find how to do that, and all of my production machinese have 64bit python installed on them. Any help at this point would be appreciated. Thanks. -- uberSVN's rich system and user administration capabilities and model configuration take the hassle out of deploying and managing Subversion and the tools developers use with it. Learn more about uberSVN and get a free download at: http://p.sf.net/sfu/wandisco-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Bus error when using logarithmic scale with logaritmic bins
Hi Ben, I will try to do it. Once it is done I let you know. Cheers, marc On Wed, Aug 10, 2011 at 7:41 PM, Benjamin Root ben.r...@ou.edu wrote: On Wed, Aug 10, 2011 at 12:32 PM, Marc Magrans de Abril marcmagransdeab...@gmail.com wrote: Dear colleagues, I'm trying to display an histogram with logarithmic bins using the logarithmic scale in the x-axis. When I execute the attached python script it crashes giving a Bus Error message (see also the attached core dump). If I remove the line plt.xscale('log') the script goes up to the end. I'm running the program on MacOS 10.6.8, Python 2.5, numpy 1.2.1, and matplotlib 0.98.5.2. Anyone knows the reason of the crash? Thanks, marc If I remember correctly, there was a log-scale bug in plt.hist() that got fixed a little while back. Your version of numpy and matplotlib is a little old. Is it possible to update those two packages on your system? Ben Root -- uberSVN's rich system and user administration capabilities and model configuration take the hassle out of deploying and managing Subversion and the tools developers use with it. Learn more about uberSVN and get a free download at: http://p.sf.net/sfu/wandisco-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Window appears, no graph drawn Fw: Plot show() errors, Mac OS 10.6
I just wanted to add that I'm getting the exact same error. On a fresh, new iMac running 10.6.8, I installed ActivePython 2.6, along with matplotlib for 2.6 on OSX. Running example code from the matplotlib website, I get the same error-- the window appears with the resizing tools but otherwise blank, and the program throws the listed Tcl error. Any ideas? Thank you for your help, Andrew Nate Gallagher wrote: Please help. -Nate - Forwarded Message From: Nate Gallagher nate.gallag...@yahoo.com To: matplotlib-users@lists.sourceforge.net Sent: Mon, March 28, 2011 2:41:39 PM Subject: [Matplotlib-users] Plot show() errors, Mac OS 10.6 operating system $ uname -a Darwin nate-gallaghers-macbook-pro.local 10.6.0 Darwin Kernel Version 10.6.0: Wed Nov 10 18:13:17 PST 2010; root:xnu-1504.9.26~3/RELEASE_I386 i386 matplotlib version: matplotlib-1.0.1-python.org-32bit-py2.7-macosx10.3.dmg obtained from: http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-1.0.1/ no o customizations to matplotlibrc $ python simple_plot.py --verbose-helpful $HOME=/Users/ibook CONFIGDIR=/Users/ibook/.matplotlib matplotlib data path /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/mpl-data a loaded rc file /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/mpl-data/matplotlibrc c matplotlib version 1.0.1 verbose.level helpful interactive is False units is False platform is darwin Using fontManager instance from /Users/ibook/.matplotlib/fontList.cache backend TkAgg version 8.5 findfont: Matching :family=sans-serif:style=normal:variant=normal:weight=normal:stretch=normal:size=medium m to Bitstream Vera Sans (/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf) ) with score of 0.00 Exception in Tkinter callback Traceback (most recent call last): File /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py, , line 1410, in __call__ return self.func(*args) File /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.py, , line 245, in resize self.show() File /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.py, , line 249, in draw tkagg.blit(self._tkphoto, self.renderer._renderer, colormode=2) File /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/tkagg.py, , line 19, in blit tk.call(PyAggImagePhoto, photoimage, id(aggimage), colormode, id(bbox_array)) TclError -- Create and publish websites with WebMatrix Use the most popular FREE web apps or write code yourself; WebMatrix provides all the features you need to develop and publish your website. http://p.sf.net/sfu/ms-webmatrix-sf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Create and publish websites with WebMatrix Use the most popular FREE web apps or write code yourself; WebMatrix provides all the features you need to develop and publish your website. http://p.sf.net/sfu/ms-webmatrix-sf ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- View this message in context: http://old.nabble.com/Window-appears%2C-no-graph-drawn-Fw%3A--Plot-show%28%29-errors%2C-Mac-OS-10.6-tp31279007p32267934.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- uberSVN's rich system and user administration capabilities and model configuration take the hassle out of deploying and managing Subversion and the tools developers use with it. Learn more about uberSVN and get a free download at: http://p.sf.net/sfu/wandisco-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Plotting arrows in a wxPython frame
Hello! I'm using matplotlib in my wx.Frame to draw some arrows and text at a certain position. The number and position of the arrows is based on previously created data. I do some calculations but basically it's like this: arrow = primer for each primer: draw one arrow at position y - 0.05 to the previos arrow (primer_y - 0.05). The x position of the arrow comes from the data, which is calculated and scaled (not so important know, it's just to now where the arrow should be at primer_x). Everything works fine until I have many arrows to draw. E.g. in my code example the data contain 62 arrows, where 18 are drawn correctly, the next 3 are missing but the text is there and the rest is completly missing. Does anyone knows what could be the problem? I tried allready to change the FigureSize but it's only stretch the arrows. Here's a quick and dirty working example, data is included in the code: http://pastebin.com/7mQmZm2c Any help is highly appreciated! Thanks in advance! Stefanie -- uberSVN's rich system and user administration capabilities and model configuration take the hassle out of deploying and managing Subversion and the tools developers use with it. Learn more about uberSVN and get a free download at: http://p.sf.net/sfu/wandisco-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Bus error when using logarithmic scale with logaritmic bins
Dear colleagues, I'm trying to display an histogram with logarithmic bins using the logarithmic scale in the x-axis. When I execute the attached python script it crashes giving a Bus Error message (see also the attached core dump). If I remove the line plt.xscale('log') the script goes up to the end. I'm running the program on MacOS 10.6.8, Python 2.5, numpy 1.2.1, and matplotlib 0.98.5.2. Anyone knows the reason of the crash? Thanks, marc Process: Python [12279] Path: /Library/Frameworks/Python.framework/Versions/2.5/Resources/Python.app/Contents/MacOS/Python Identifier: org.python.python Version: 2.5a0 (2.5alpha0) Code Type: X86 (Native) Parent Process: bash [11351] Date/Time: 2011-08-10 19:29:03.082 +0200 OS Version: Mac OS X 10.6.8 (10K549) Report Version: 6 Interval Since Last Report: 1008 sec Crashes Since Last Report: 3 Per-App Interval Since Last Report: 33 sec Per-App Crashes Since Last Report: 3 Anonymous UUID: 22EF-1C96-47F9-BECD-21497E29C337 Exception Type: EXC_BAD_ACCESS (SIGBUS) Exception Codes: KERN_PROTECTION_FAILURE at 0x Crashed Thread: 0 Dispatch queue: com.apple.main-thread Thread 0 Crashed: Dispatch queue: com.apple.main-thread 0 ??? 00 0 + 0 1 libSystem.B.dylib 0x9a9c8f68 _Unwind_GetLanguageSpecificData + 24 2 libstdc++.6.dylib 0x948fcd86 __gxx_personality_v0 + 120 3 libgcc_s.1.dylib0x01759476 _Unwind_RaiseException_Phase2 + 102 (unwind.inc:68) 4 libgcc_s.1.dylib0x01759890 _Unwind_Resume + 112 (unwind.inc:238) 5 _backend_agg.so 0x02a344c0 py_to_agg_transformation_matrix(Py::Object const, bool) + 580 6 _backend_agg.so 0x02a3c5a5 RendererAgg::draw_path(Py::Tuple const) + 281 7 _backend_agg.so 0x02a4daea Py::PythonExtensionRendererAgg::method_varargs_call_handler(_object*, _object*) + 400 8 org.python.python 0x0009761c PyEval_EvalFrameEx + 18969 (ceval.c:3566) 9 org.python.python 0x00099482 PyEval_EvalCodeEx + 1819 (ceval.c:2833) 10 org.python.python 0x00097108 PyEval_EvalFrameEx + 17669 (ceval.c:3662) 11 org.python.python 0x00099482 PyEval_EvalCodeEx + 1819 (ceval.c:2833) 12 org.python.python 0x00097108 PyEval_EvalFrameEx + 17669 (ceval.c:3662) 13 org.python.python 0x00099482 PyEval_EvalCodeEx + 1819 (ceval.c:2833) 14 org.python.python 0x00097108 PyEval_EvalFrameEx + 17669 (ceval.c:3662) 15 org.python.python 0x000982e4 PyEval_EvalFrameEx + 22241 (ceval.c:3652) 16 org.python.python 0x00099482 PyEval_EvalCodeEx + 1819 (ceval.c:2833) 17 org.python.python 0x0002edfb function_call + 320 (funcobject.c:517) 18 org.python.python 0xdceb PyObject_Call + 45 (abstract.c:1860) 19 org.python.python 0x0001580c instancemethod_call + 401 (classobject.c:2493) 20 org.python.python 0xdceb PyObject_Call + 45 (abstract.c:1860) 21 org.python.python 0x0009594d PyEval_EvalFrameEx + 11594 (ceval.c:3777) 22 org.python.python 0x00099482 PyEval_EvalCodeEx + 1819 (ceval.c:2833) 23 org.python.python 0x00097108 PyEval_EvalFrameEx + 17669 (ceval.c:3662) 24 org.python.python 0x00099482 PyEval_EvalCodeEx + 1819 (ceval.c:2833) 25 org.python.python 0x0002edfb function_call + 320 (funcobject.c:517) 26 org.python.python 0xdceb PyObject_Call + 45 (abstract.c:1860) 27 org.python.python 0x000965d4 PyEval_EvalFrameEx + 14801 (ceval.c:3846) 28 org.python.python 0x00099482 PyEval_EvalCodeEx + 1819 (ceval.c:2833) 29 org.python.python 0x0002edfb function_call + 320 (funcobject.c:517) 30 org.python.python 0xdceb PyObject_Call + 45 (abstract.c:1860) 31 org.python.python 0x0001580c instancemethod_call + 401 (classobject.c:2493) 32 org.python.python 0xdceb PyObject_Call + 45 (abstract.c:1860) 33 org.python.python 0x00091d7e PyEval_CallObjectWithKeywords + 112 (ceval.c:3435) 34 _tkinter.so 0x024dfe57 PythonCmd + 220 (_tkinter.c:2012) 35 Tcl 0x02663f78 TclInvokeStringCommand + 110 36 Tcl 0x02666182 TclEvalObjvInternal + 984 37 Tcl 0x0268d68f TclExecuteByteCode + 3487 38 Tcl 0x02692f10 Tcl_ExprObj + 1090 39 Tcl 0x02664d35 Tcl_ExprBooleanObj + 46 40 Tcl 0x02672ca7
[Matplotlib-users] absolute error of curve fit parameters
Hi, I'm a little bit desperated. I googled for days to find an appropriate way to calculate the absolute errors of parameters of non-linear fits. I found different sites which suggest different, sometimes more or less similar ways. But the results don't make sense. Here is a simple example: from pylab import * from scipy.optimize import curve_fit def f(x,a,b): return a*x+b def fit(n=1000): x,y=array([0,1,1]),array([1,2,4]) xf=[(min(x)+i*(max(x)-min(x))/float(n)) for i in range(0,int(n)+1)] a,acov=curve_fit(f,x,y) yf=[f(*tuple([i]+list(a))) for i in xf] meansq=sum([pow(y[i]-f(x[i],a[0],a[1]),2)/(len(x)) for i in range(0,len(x))]) redchi2=sum([pow(y[i]-f(x[i],a[0],a[1]),2)/(len(x)-len(a)) for i in range(0,len(x))]) print 'standard dev:',sqrt(diag(acov)) print 'abs. meansq err.:',[acov[i][i]*sqrt(meansq) for i in range(0,len(a))] print 'abs. reduced meansq err.:',[acov[i][i]*sqrt(redchi2) for i in range(0,len(a))] fit() I included 3 ways I found. The used arrays have 3 points, where for x=1 I give 2 different y values. I would say, a=2+/-1, b=1+/-0, but no way yields to a similar result! How can I trust this function on more complicated, really non-linear functions? Or is simply this example wrong? Or are the methods not right? I'm very thankful for any help! Best regards, André -- View this message in context: http://old.nabble.com/absolute-error-of-curve-fit-parameters-tp32269685p32269685.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- uberSVN's rich system and user administration capabilities and model configuration take the hassle out of deploying and managing Subversion and the tools developers use with it. Learn more about uberSVN and get a free download at: http://p.sf.net/sfu/wandisco-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] How to get correct xtick labels with zooming and panning
I ended up creating a wrapper around the toolbar and resetting the labels and redrawing whenever something changes. Is there a cleaner way? class WrappedNavigationToolbar(NavigationToolbar): def __init__(self, viewer, canvas, parent): self.viewer = viewer super(WrappedNavigationToolbar, self).__init__(canvas, parent) def release_zoom(self, event): print release zoom super(WrappedNavigationToolbar, self).release_zoom(event) self.viewer.resetLabels() self.draw() def release_pan(self, event): print release_pan super(WrappedNavigationToolbar, self).release_pan(event) self.viewer.resetLabels() self.draw() def home(self, *args): print home super(WrappedNavigationToolbar, self).home(*args) self.viewer.resetLabels() self.draw() def forward(self, *args): print forward super(WrappedNavigationToolbar, self).forward(*args) self.viewer.resetLabels() self.draw() def back(self, *args): print back super(WrappedNavigationToolbar, self).back(*args) self.viewer.resetLabels() self.draw() . def resetLabels(self): xlabels = self.plotInfo.getXValues() xticks = self.axes.get_xticks() newticks = [] for label in xticks: idx = int(label) if idx =0 and idx len(xlabels): newticks.append(xlabels[idx]) else: newticks.append() self.axes.set_xticklabels(newticks) From: Fiedler, Lars - 0447 - MITLL Sent: Thursday, August 11, 2011 6:10 PM To: matplotlib-users@lists.sourceforge.net Cc: Fiedler, Lars - 0447 - MITLL Subject: How to get correct xtick labels with zooming and panning Hi, If I create a bar graph inside a FigureCanvas, how do I get the correct x tick labels to display when someone does a zoom with the NavigationToolbar? For example, lets say I've got the below code: self.axes.set_xticks = range(len(vals)) self.axes.set_xticklabels(xLabels) self.axes.bar( left=range(len(vals)), height=map(float, vals), width=.2, align='center', alpha=0.44, picker=5) If the number of values is very large, then matplotlib seems to select only a few x labels to display (selecting far left and right, and some in the middle), but it's choosing the first ones in the specified label array, instead of indexing into it. I've tried setting the tick labels, based on the ticks it's selected, (setting labels based on the ticks after the bar has been created) and that seems to work on the initial load, but then if someone zooms into a particular part, it doesn't update the labels to the correct range . It's almost like I would need a callback to reset the labels . Ideas? Cheers, Lars smime.p7s Description: S/MIME cryptographic signature -- uberSVN's rich system and user administration capabilities and model configuration take the hassle out of deploying and managing Subversion and the tools developers use with it. Learn more about uberSVN and get a free download at: http://p.sf.net/sfu/wandisco-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] absolute error of curve fit parameters
On Tue, Aug 16, 2011 at 2:15 AM, 4ndre andre.dank...@gmail.com wrote: Hi, I'm a little bit desperated. I googled for days to find an appropriate way to calculate the absolute errors of parameters of non-linear fits. I found different sites which suggest different, sometimes more or less similar ways. But the results don't make sense. Here is a simple example: from pylab import * from scipy.optimize import curve_fit def f(x,a,b): return a*x+b def fit(n=1000): x,y=array([0,1,1]),array([1,2,4]) xf=[(min(x)+i*(max(x)-min(x))/float(n)) for i in range(0,int(n)+1)] a,acov=curve_fit(f,x,y) yf=[f(*tuple([i]+list(a))) for i in xf] meansq=sum([pow(y[i]-f(x[i],a[0],a[1]),2)/(len(x)) for i in range(0,len(x))]) redchi2=sum([pow(y[i]-f(x[i],a[0],a[1]),2)/(len(x)-len(a)) for i in range(0,len(x))]) print 'standard dev:',sqrt(diag(acov)) print 'abs. meansq err.:',[acov[i][i]*sqrt(meansq) for i in range(0,len(a))] print 'abs. reduced meansq err.:',[acov[i][i]*sqrt(redchi2) for i in range(0,len(a))] fit() I included 3 ways I found. The used arrays have 3 points, where for x=1 I give 2 different y values. I would say, a=2+/-1, b=1+/-0, but no way yields to a similar result! How can I trust this function on more complicated, really non-linear functions? Or is simply this example wrong? Or are the methods not right? I'm very thankful for any help! Best regards, André Andre, Typically, I do something like the following: from scipy.optimize import polyfit, polyval import numpy as np. # x and y are arrays of floats a, b = polyfit(x, y, 1) # first-order polynomial y_fit = polyval([a, b], x) mean_abs_err = np.mean(np.abs(y_fit - y)) I hope that helps! Ben Root -- uberSVN's rich system and user administration capabilities and model configuration take the hassle out of deploying and managing Subversion and the tools developers use with it. Learn more about uberSVN and get a free download at: http://p.sf.net/sfu/wandisco-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Key_press_event with Qt4Agg backend
I've been trying the Qt4Agg backend for matplotlib and I've encountered two problems. The following code illustrates the issues: import matplotlib matplotlib.use('Qt4Agg') import matplotlib.pyplot as plt plt.ion() plt.plot([1,2,3]) canvas=plt.gcf().canvas def on_key(event): print 'you pressed', event.key, event.xdata, event.ydata canvas.mpl_connect('key_press_event', on_key) The problems: 1) The user has to click within the canvas before key press events are registered. Activating the window is not sufficient. 2) Keys 'up', 'down', 'left', 'right', 'pageup', and 'pagedown' all return event.key=None. The tkagg and gtkagg backends don't have these problems - key press events are active as soon as the window is active, and event.key reports the correct key. Does anyone have an idea why these problems are cropping up with Qt4 or know a workaround? Thanks, -Andrew Mark -- uberSVN's rich system and user administration capabilities and model configuration take the hassle out of deploying and managing Subversion and the tools developers use with it. Learn more about uberSVN and get a free download at: http://p.sf.net/sfu/wandisco-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] adding custom legends to multicolored line
Hi , I wish to add a custom legend to a multicolored line drawn using matplotlib as shown in the figure below http://www.scipy.org/Cookbook/Matplotlib/MulticoloredLine I tried exploring the legend but somehow couldn't figure out its usage and how to adapt it to multicolored line as in the above link I need to use say Red line for label1 and blue line for label2 and green line for label3. All the three colors are a part of a single sinusoidal wave as in the above link. Any thoughts/ideas/suggestions which could provide me some direction on this would be highly appreciated. -- Thanks and Regards, RaviKanth -- uberSVN's rich system and user administration capabilities and model configuration take the hassle out of deploying and managing Subversion and the tools developers use with it. Learn more about uberSVN and get a free download at: http://p.sf.net/sfu/wandisco-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] [matplotlib-devel] Calling all Mac OSX users!
On Mon, Aug 15, 2011 at 9:34 PM, Benjamin Root ben.r...@ou.edu wrote: The mpl developers are getting very close to the long-awaited v1.1.0 release of matplotlib. Before we do so, we are doing some final checking of the documentation to make sure that all critical pieces of information iss correct and up to date. In checking over the instructions for building and installing matplotlib on MacOSX, I have found two separate sets of instructions. On the install page, there is a reference to a README.txt file in release/osx. This file is there, but it seems to refer to other files that no longer exists. Meanwhile, there is an un-referenced file in the top directory called README.osx that seems a lot more current. Because I do not have a Mac that I can use for development, I would like to ask the community for help in determining the correct set of instructions and to eliminate cruft. I think it would also be useful to point users to any relevant instructions for installing/building numpy on Macs. I would also like to make sure we are current with information on installing on a stock Lion install. Please feel free to respond on this list, or better, make a branch on github and submit pull requests to help us improve these documents. I wrote both of those files originally (make.osx and releases/osx/*). The original division of labor was the stuff in releases was designed to build the release binaries, and the stuff in make.osx was primarily used to build from svn or src. Overtime, most of the effort has gone into make.osx, and it now includes support for binaries. I no longer build the OSX binaries (Russell does) and no longer use OS X (back to ubuntu) so if Russell is not using the stuff in releases/osx, we can flush it. JDH -- Get a FREE DOWNLOAD! and learn more about uberSVN rich system, user administration capabilities and model configuration. Take the hassle out of deploying and managing Subversion and the tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] mathtext in eps figures doesn't come out in pdf
Hi all, I've been making figures for a paper I'm writing (to be submitted to the ApJ). I'm using LaTeX and so need to use encapsulated PostScript for the figures. The problem is that when the paper is translated to pdf from PostScript, the mathtext in the figures disappears. The reason that I think this is a matplotlib issue is that it's never happened to me with eps figures created in different ways. It's clear that this must be related to fonts, but I'm not sure how to get around it. Should I set text.usetex to True? I have a feeling this issue must have come up before, but I haven't found anything obviously pertinent in the mailing list archives. Jon -- Get a FREE DOWNLOAD! and learn more about uberSVN rich system, user administration capabilities and model configuration. Take the hassle out of deploying and managing Subversion and the tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] mathtext in eps figures doesn't come out in pdf
Hi all, I've been making figures for a paper I'm writing (to be submitted to the ApJ). I'm using LaTeX and so need to use encapsulated PostScript for the figures. The problem is that when the paper is translated to pdf from PostScript, the mathtext in the figures disappears. The reason that I think this is a matplotlib issue is that it's never happened to me with eps figures created in different ways. It's clear that this must be related to fonts, but I'm not sure how to get around it. Should I set text.usetex to True? I have a feeling this issue must have come up before, but I haven't found anything obviously pertinent in the mailing list archives. Jon Are you dead set on using eps files? If the journal doesn't mind, you could always save your figures as pdf files using the pdf backend, then you can use pdflatex on everything and you never have to generate a postscript file. Damon McDougall d.mcdoug...@warwick.ac.uk http://damon.is-a-geek.com B2.39 Mathematics Institute Coventry West Midlands CV4 7AL -- Get a FREE DOWNLOAD! and learn more about uberSVN rich system, user administration capabilities and model configuration. Take the hassle out of deploying and managing Subversion and the tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] errorbar plot with different markers
Hi All, A question for a possible new feature for Matplotlib. First, in case there is a way to do it currently: I often find myself plotting data with errorbars, and I would like to be able to modify the marker, or marker size of each individual point separately. A (seemingly to me) natural way to do this would allow marker markersize markerfacecolor markeredgecolor etc accept arrays, as well as a single kwarg. As far as I can tell, if I have a set of data, and I want to make the markers with different sizes, the only way to do this is have a loop that calls each data point individually and assigns the marker features. 1 - am I mistaken? and if so, could someone instruct me how to achieve my goal 2 - does anyone else find this feature desirable? If so, could this be added to Matplotlib? I have not the coding experience to attempt this myself - but I imagine the simplest thing to do would be check if the marker, ms, etc are given single kwargs, or arrays. If single, everything happens as now. If array, then check the len of the array against the len of the data, and if the same, match the entries. Thanks, Andre -- Get a FREE DOWNLOAD! and learn more about uberSVN rich system, user administration capabilities and model configuration. Take the hassle out of deploying and managing Subversion and the tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] plot() not using alpha value from RGBA tuple
On Tue, Aug 16, 2011 at 12:22 AM, Benjamin Root ben.r...@ou.edu wrote: On Monday, August 15, 2011, Ben Breslauer bbresla...@gmail.com wrote: Hi, Has anyone else noticed this behavior? For the devs, do you prefer a github bug to the SF list? Ben I have not personally observed this, but usually, people don't specify rgba tuples for plot. I think the lack of response is due to our focus on larger bugs right now for the upcoming release. Therefore, it would probably be best to file a bug report with your patch so that we have a record of it. The fuller patch might be more involved (consider scatter and other functions). Plus, we would likely need to consider what to do if both an rgba tuple and alpha were specified, As a rule of thumb, if we don't respond on list, file a bug report. Thanks for bringing this to our attention! Ben Root Ben, Eric, and Vlastimil, Thanks for the responses. I will try and submit a bug report soon, and perhaps a patch if I can come up with something more complete, though obviously I don't know the matplotlib code base all that well. And I'll keep that rule of thumb in mind in the future. Ben -- Get a FREE DOWNLOAD! and learn more about uberSVN rich system, user administration capabilities and model configuration. Take the hassle out of deploying and managing Subversion and the tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] mathtext in eps figures doesn't come out in pdf
Can you post an output eps file so that we can take a look? Regards, -JJ On Wed, Aug 17, 2011 at 5:52 AM, Jonathan Slavin jsla...@cfa.harvard.edu wrote: Hi all, I've been making figures for a paper I'm writing (to be submitted to the ApJ). I'm using LaTeX and so need to use encapsulated PostScript for the figures. The problem is that when the paper is translated to pdf from PostScript, the mathtext in the figures disappears. The reason that I think this is a matplotlib issue is that it's never happened to me with eps figures created in different ways. It's clear that this must be related to fonts, but I'm not sure how to get around it. Should I set text.usetex to True? I have a feeling this issue must have come up before, but I haven't found anything obviously pertinent in the mailing list archives. Jon -- Get a FREE DOWNLOAD! and learn more about uberSVN rich system, user administration capabilities and model configuration. Take the hassle out of deploying and managing Subversion and the tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Get a FREE DOWNLOAD! and learn more about uberSVN rich system, user administration capabilities and model configuration. Take the hassle out of deploying and managing Subversion and the tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users