Re: [Matplotlib-users] mplot3d bar3d errors
Hi Derek, I just tried your program with the latest svn version and that seems to work fine, so I'd suggest you try that as well [1]. It looks to me like the fix should be present in 0.99.1-2 too [2]. Please let me know if you still run into the same problem. Cheers, Reinier [1] http://matplotlib.sourceforge.net/faq/installing_faq.html#install-from-svn [2] http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-0.99.1/ On Wed, Jan 27, 2010 at 3:08 AM, Derek Schuff dsch...@purdue.edu wrote: Hi all, I'm getting strange errors trying to use the bar3d method in mplot3d (I'm using matplotlib 0.99.0 in Ubuntu 9.10 and Python 2.6). I'm doing something roughly like the example at http://matplotlib.sourceforge.net/examples/mplot3d/hist3d_demo.html I've pasted my sample program below, which has 2 cases: In case 1, you see just what you would expect: 2 rows of bars with increasing size in the y direction. if you uncomment case 2 (for different bar heights), you get the following error: Traceback (most recent call last): File /usr/lib/pymodules/python2.6/matplotlib/backends/backend_gtk.py, line 352, in expose_event self._render_figure(self._pixmap, w, h) File /usr/lib/pymodules/python2.6/matplotlib/backends/backend_gtkagg.py, line 75, in _render_figure FigureCanvasAgg.draw(self) File /usr/lib/pymodules/python2.6/matplotlib/backends/backend_agg.py, line 314, in draw self.figure.draw(self.renderer) File /usr/lib/pymodules/python2.6/matplotlib/artist.py, line 46, in draw_wrapper draw(artist, renderer, *kl) File /usr/lib/pymodules/python2.6/matplotlib/figure.py, line 774, in draw for a in self.axes: a.draw(renderer) File /usr/lib/pymodules/python2.6/mpl_toolkits/mplot3d/axes3d.py, line 135, in draw for col in self.collections] File /usr/lib/pymodules/python2.6/mpl_toolkits/mplot3d/art3d.py, line 334, in do_3d_projection z_segments_2d.sort(reverse=True) ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() This error gets thrown any time the 2 bars in the same y position have exactly the same z value: in the sample program the (0,0) value and (0,1) value are both 1 but it works for any of the 4 pairs. The error is particularly confusing. even looking at the source of the sort line in the backtrace, it's not clear where any arrays are being used as truth values. (just compared for the sort). This can be worked around by adding a tiny delta to the z values in one of the rows: it only errors when the corresponding z values match exactly. Am I doing something wrong here? or is this some kind of bug in the drawing code? thanks, -Derek the program: #!/usr/bin/env python2.6 import matplotlib.pyplot as plot import mpl_toolkits.mplot3d import numpy fig2 = plot.figure() ax2 = mpl_toolkits.mplot3d.Axes3D(fig2) xpos = numpy.asarray([0, 1, 2, 4, 0, 1, 2, 4]) ypos = numpy.asarray([0, 0, 0, 0, 1, 1, 1, 1]) zpos = numpy.zeros_like(xpos) dx = 0.05 * numpy.ones_like(zpos) dy = numpy.ones_like(zpos) #case 1 dz = numpy.asarray([1,2,3,4,5,6,7,8]) #case 2 #dz = numpy.asarray([1,2,3,4,1,6,7,8]) ax2.bar3d(ypos, xpos, zpos, dy, dx, dz, color='b') ax2.set_xlabel('X') ax2.set_ylabel('Y') ax2.set_zlabel('Z') plot.show() -- 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 -- Reinier Heeres Tel: +31 6 10852639 -- 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] How to change tick labels?
Hi, I have a very crowded plot with lots of subplots, and tick labels tend to overlap. I wanted to drop e.g. the 1st and last x-tick labels for each subplot, doing something like: ax = P.subplot(1,1,1) ax.plot([1,2,3,2,1,2,3]) ax.set_xticklabels(['']+ [ lbl.get_text() for lbl in ax.get_xticklabels()[1:-1] ]+ ['']) This works in interactive 'ipython -pylab', but this does not work anymore in a script: in my script, the tick label returned by ax.get_xticklabels() are all empty strings: print [ lbl.get_text() for lbl in ax.get_xticklabels() ] returns ['', '', '', '', '', '', ''] It seems the tick text strings are filled in only at the very last moment (at show() time?). Any help out there? Cheers, -- .~. Yannick COPIN (o:* Doctus cum libro /V\ Institut de physique nucléaire de Lyon // \\ Université de Lyon - CNRS-IN2P3 /( )\ AIM: YnCopin ICQ: 236931013 ^`~'^ http://snovae.in2p3.fr/ycopin/ -- 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] defining/saving contours without plotting
To matplotusers: I want to create a plot that has an image and overplots contours, but the contours are defined relative to different data from that plotted in the image. Is there a way to save contour line data rather than plot it. It just occurred to me a way of creating the plot -- but I'm still interested in a way to save contour data. Jon -- __ Jonathan D. Slavin Harvard-Smithsonian CfA jsla...@cfa.harvard.edu 60 Garden Street, MS 83 phone: (617) 496-7981 Cambridge, MA 02138-1516 cell: (781) 363-0035 USA __ -- 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] plot coordinates points
Hey all how to plot a point coordinates in matplotlib? I want for example to plot the point of coordinates x=1.2,y=2.5 Cheers -- 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
Re: [Matplotlib-users] plot coordinates points
Hi, do you mean a single point with coordinates x and y like plot([1.2], [2.5], marker='+') Regards, Matthias On Wednesday 27 January 2010 17:26:39 franck kalala wrote: Hey all how to plot a point coordinates in matplotlib? I want for example to plot the point of coordinates x=1.2,y=2.5 Cheers -- 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
Re: [Matplotlib-users] defining/saving contours without plotting
Hi Jon, one thing you can do is to get the (x, y)-values of the calculated contourlines: cs = plt.contour(z, levels=[0]) a = cs.collections[0].get_paths()[0].vertices # - array of shape (..., 2) hold x and y in first and second column I don't know wheter this is the best way, but at least for me it works. Kind regards, Matthias On Wednesday 27 January 2010 15:14:27 Jonathan Slavin wrote: To matplotusers: I want to create a plot that has an image and overplots contours, but the contours are defined relative to different data from that plotted in the image. Is there a way to save contour line data rather than plot it. It just occurred to me a way of creating the plot -- but I'm still interested in a way to save contour data. Jon -- 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