Re: [Matplotlib-users] Colormap cluttering?
Hi andrew, eric, Excellent that is exactly what I was looking for :) Laurent > -Message d'origine- > De : Eric Firing [mailto:[EMAIL PROTECTED] > Envoyé : mardi 29 juillet 2008 02:39 > À : Laurent Dufrechou > Cc : matplotlib-users@lists.sourceforge.net > Objet : Re: [Matplotlib-users] Colormap cluttering? > > Laurent Dufrechou wrote: > > Hello, > > > > > > > > I would like to have a cluttering functionality to colorbar. > > > > http://en.wikipedia.org/wiki/Clutter_(radar) > > > > > > > > Before writing it, I would like to know if there is a way to doing it > > with matplotlib. > > > > What I mean by cluttering is: > > > > > > > > Youve got a colormap associated with a graphic where value goes from > 0 > > to 255 for example. > > > > Assigning a classical colormap (for example cm.jet) 0 value will be > blue > > and 255 one will be red. > > > > What I need is a low clutter and max clutter, if I set low clutter > to > > 10 and ax cluter to 250 then: > > > > Blue will be for value from 0 to 10 > > > > Then the colormap do his job from 10 to 250 and finally > > > > From 250 to 255 colr will be set to max one = red. > > > > > > > > Is it ever done in matplotlib, if not what could be the strategy > here ? > > > > I was thinking of set_over/set_under but seems not be exactly what I > > need because I want to recreate the colormap from 10 to 250 with N > segments. > > > > (moreover I dont understand how you set the over/under value ) > > If you don't really care how many colors are in the map, then for your > 0-255 example, try this: > > import numpy as np > import matplotlib.pyplot as plt > fakedata = np.random.rand(10,20) * 255.0 > cmap = plt.cm.jet > norm = plt.Normalize(vmin=100, vmax=150) > plt.imshow(fakedata, cmap=cmap, norm=norm, interpolation="nearest") > plt.colorbar(extend="both") > plt.show() > > I made the colored range small to emphasize what you call the > "cluttering" effect. > > We are taking advantage of the default, which is that the over and > under > values are the top and bottom ends of the colormap. If you want other > colors for the ends, then after defining your cmap, use, e.g.: > > cmap.set_under('w') > cmap.set_over('k') > > If you want to use a smaller number of colors in your colormap, then > you > need to make the colormap this way, for example: > > from matplotlib.colors import LinearSegmentedColormap > from matplotlib._cm import _jet_data > cmap = LinearSegmentedColormap("yourname", _jet_data, N=10) > > (I should add a helper function to make this more obvious and > straightforward.) > > Eric - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] text picker
Text picking does not seem to work for me anymore since I upgraded from 0.91.4 to 0.98.1. These lines should set up the picker. They come straight from "pick_event_demo.py" ax1.set_title('click on points, rectangles or text', picker=True) ax1.set_ylabel('ylabel', picker=True, bbox=dict(facecolor='red')) fig.canvas.mpl_connect('pick_event', onpick1) def onpick1(event): if isinstance(event.artist, Line2D): thisline = event.artist xdata = thisline.get_xdata() ydata = thisline.get_ydata() ind = event.ind print 'onpick1 line:', zip(npy.take(xdata, ind), npy.take(ydata, ind)) elif isinstance(event.artist, Rectangle): patch = event.artist print 'onpick1 patch:', patch.get_path() elif isinstance(event.artist, Text): text = event.artist print 'onpick1 text:', text.get_text() I apologize if this is a known issue. I tried searching the listserve, but did not find anything. -Ben - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] text picker
On Tue, Jul 29, 2008 at 10:55 AM, Ben Axelrod <[EMAIL PROTECTED]> wrote: > Text picking does not seem to work for me anymore since I upgraded from > 0.91.4 to 0.98.1. This is fixed in matplotlib svn and will be out in the next release. - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] bar plot picker with 0 height data
I get an exception when I set up a bar chart with a picker that has a bar with 0 height, and I click on the chart. Code to generate exception: from matplotlib.pyplot import figure, show import numpy as np def onpick1(event): print 'foo' fig = figure() ax = fig.add_subplot(111) xdata = [1, 2, 3] ydata = [1, 0, 3] #change to [1, 2, 3] and code will run fine ax.bar(xdata, ydata, picker = True) fig.canvas.mpl_connect('pick_event', onpick1) show() #now click on chart - Exception generated: Exception in Tkinter callback Traceback (most recent call last): File "C:\Python24\lib\lib-tk\Tkinter.py", line 1345, in __call__ return self.func(*args) File "C:\Python24\Lib\site-packages\matplotlib\backends\backend_tkagg.py", line 236, in button_press_event FigureCanvasBase.button_press_event(self, x, y, num, guiEvent=event) File "C:\Python24\Lib\site-packages\matplotlib\backend_bases.py", line 1074, in button_press_event self.callbacks.process(s, mouseevent) File "C:\Python24\Lib\site-packages\matplotlib\cbook.py", line 152, in process func(*args, **kwargs) File "C:\Python24\Lib\site-packages\matplotlib\backend_bases.py", line 983, in pick self.figure.pick(mouseevent) File "C:\Python24\Lib\site-packages\matplotlib\artist.py", line 226, in pick for a in self.get_children(): a.pick(mouseevent) File "C:\Python24\Lib\site-packages\matplotlib\axes.py", line 2306, in pick martist.Artist.pick(self,args[0]) File "C:\Python24\Lib\site-packages\matplotlib\artist.py", line 226, in pick for a in self.get_children(): a.pick(mouseevent) File "C:\Python24\Lib\site-packages\matplotlib\artist.py", line 220, in pick inside,prop = self.contains(mouseevent) File "C:\Python24\Lib\site-packages\matplotlib\patches.py", line 385, in contains x, y = self.get_transform().inverted().transform_point( File "C:\Python24\Lib\site-packages\matplotlib\transforms.py", line 1840, in inverted return CompositeGenericTransform(self._b.inverted(), self._a.inverted()) File "C:\Python24\Lib\site-packages\matplotlib\transforms.py", line 1338, in inverted self._inverted = Affine2D(inv(mtx)) File "C:\Python24\Lib\site-packages\numpy\linalg\linalg.py", line 332, in inv return wrap(solve(a, identity(a.shape[0], dtype=a.dtype))) File "C:\Python24\Lib\site-packages\numpy\linalg\linalg.py", line 235, in solve raise LinAlgError, 'Singular matrix' LinAlgError: Singular matrix -- Stats: MPL 0.98.1 Python 2.4.4 Numpy 1.1.0 I get the error on both Windows and Linux Thanks, -Ben - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] bar plot picker with 0 height data
On Tue, Jul 29, 2008 at 12:27 PM, Ben Axelrod <[EMAIL PROTECTED]> wrote: > I get an exception when I set up a bar chart with a picker that has a bar > with 0 height, and I click on the chart. Thanks for the report -- I just committed a fix for this to svn r5922 JDH - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] matplotlib 0.98.3 release candidate, please test
We are in the final stages of preparing a new matplotlib release, and a lot of work has gone into it. If you would like to test the release and see if it is working for you, that would be a big help http://matplotlib.sourceforge.net/tmp/matplotlib-0.98.3rc2.tar.gz Unfortunately, we do not have binary builds available at this time. Sandro, I saw that Georg released the 0.4.2 sphinx bugfix release, so as soon as Mikhail gets that into debian you can test this release candidate. JDH - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] bar plot picker with 0 height data
Thanks for the bug fix. Do you think this fix will make it into the 0.98.3 release? -Original Message- From: John Hunter [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 29, 2008 1:49 PM To: Ben Axelrod Cc: matplotlib-users@lists.sourceforge.net Subject: Re: [Matplotlib-users] bar plot picker with 0 height data On Tue, Jul 29, 2008 at 12:27 PM, Ben Axelrod <[EMAIL PROTECTED]> wrote: > I get an exception when I set up a bar chart with a picker that has a bar > with 0 height, and I click on the chart. Thanks for the report -- I just committed a fix for this to svn r5922 JDH - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] bar plot picker with 0 height data
On Tue, Jul 29, 2008 at 1:20 PM, Ben Axelrod <[EMAIL PROTECTED]> wrote: > Thanks for the bug fix. Do you think this fix will make it into the 0.98.3 > release? it will. - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Waterfall Plot?
I'm new to matplotlib and was hoping someone could point me in the right direction for making a waterfall plot, similar to MATLAB's 'waterfall'. I'd like to plot a series of 2-D spectra staggered by time. Thanks, Travis - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Waterfall Plot?
On Tue, Jul 29, 2008 at 1:48 PM, Travis Ruthenburg <[EMAIL PROTECTED]> wrote: > I'm new to matplotlib and was hoping someone could point me in the > right direction for making a waterfall plot, similar to MATLAB's > 'waterfall'. > > I'd like to plot a series of 2-D spectra staggered by time. The specgram function is the closest equivalent: http://matplotlib.sourceforge.net/matplotlib.pyplot.html#-specgram - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] SVG rendering problems
Hi all, With both matplotlib versions (0.91 and 0.98), my SVGs are rendered correctly in Inkscape (and almost well in Firefox), but they are not rendered correctly when viewed with ImageMagick or Eye-of-Gnome. I did screenshots here, showing this "curve cropping" issue : http://mathieu-leplatre.info/media/matplotlib-svg/ I am running CentOS 5.2 with matplotlib compiled manually in both cases. Cairo 1.2.4, librsvg 2.16, inkscape 0.46 Could it be related to matplotlib ? Or to operating system libraries ? Thank you all for your support. Mathieu. - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Waterfall Plot?
Travis Ruthenburg wrote: > I'm new to matplotlib and was hoping someone could point me in the > right direction for making a waterfall plot, similar to MATLAB's > 'waterfall'. > > I'd like to plot a series of 2-D spectra staggered by time. Travis, I presume you are handling the calculation of spectra, and the question is really about plotting offset lines. We do not have the 3-D type plot illustrated here: http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/ref/waterfall.html&http://www.mathworks.com/cgi-bin/texis/webinator/search/ but there are a couple of ways you can plot offset lines. One is to use the plot command to plot a set of lines, to which you have added the offsets yourself. The other is to make a LineCollection. I see that our example of the latter does not actually make use of the feature that automatically applies the constant offsets, so I need to make a revised example, which I can't do right this minute. In the meantime, the approach in line_collection.py and line_collection2.py in the mpl examples directory (examples/pylab_examples/ in the 0.98.x and svn versions) will work. Backing off slightly, the larger points are (1) mpl is 2-D only; there was a 3-D module in earlier versions, but it was unmaintained and has been dropped; (2) 2-D plotting is very flexible; (3) often the problem is not one of plotting but of manipulating your input arrays, so the better you know numpy, the easier and more efficiently you can generate plots. Eric - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] plotting a contour map from CSV file
Hello Jeff, I just wanna give feedback on what got me going here: data preparation ### data is loaded from a CSV file ### lats = y # data[:,0] ## lon => x lons = x # data[:,1] ## values => z values = z #data[:,2] ### lat_uniq = list(set(lats.tolist())) nlats = len(lat_uniq) lon_uniq = list(set(lons.tolist())) nlons = len(lon_uniq) color_map = plt.cm.spectral print lats.shape, nlats, nlons yre = lats.reshape(nlats,nlons) xre = lons.reshape(nlats,nlons) zre = values.reshape(nlats,nlons) later in the defined map CT = m.contourf(xre, yre, zre, cmap=color_map) Of course, this can be simplified. But, really, in the end the solution was just simple and I hadn't thought of it... If you want I can try to create a short example for the distribution. Thanks for your help again, Timmie - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] imshow update norm make my app crash.
Hi guys, continuing exploring matplotlib capabilities J I've applied the idea you've said later about colormap. Now I would like on an event to refresh my view so I've written this code: . def InitCode(self): . self.norm = plt.Normalize(vmin=0, vmax=255) self.cmap = cm.jet im_full = full_sonar.imshow( z, aspect= 'auto', cmap=self.cmap, norm=self.norm, interpolation='quadric') im_zoom = zoomed_sonar.imshow( z, aspect= 'auto',cmap=self.cmap, norm=self.norm, interpolation='quadric') self.fig.colorbar(im_full,cax=cax,orientation='vertical',extend='both') self.im_full = im_full self.im_zoom = im_zoom . def updateSonarView(self): self.im_full.set_cmap(self.cmap) self.im_zoom.set_cmap(self.cmap) self.im_full.set_norm(self.norm) self.im_zoom.set_norm(self.norm) self.fig.canvas.draw() def OnUpdateButton(self, event): self.low_clutter_val = self.clutter_low.GetPosition() self.high_clutter_val = self.clutter_high.GetPosition() self.norm = plt.Normalize(vmin=self.low_clutter_val, vmax=self.high_clutter_val) self.updateSonarView() But I get this error from the lib : Traceback (most recent call last): File "./Filters\A1Filter.py", line 183, in OnUpdateButton self.updateSonarView() File "./Filters\A1Filter.py", line 157, in updateSonarView self.im_full.set_norm(self.norm) File "C:\Python25\Lib\site-packages\matplotlib\cm.py", line 129, in set_norm self.changed() File "C:\Python25\Lib\site-packages\matplotlib\image.py", line 123, in changed cm.ScalarMappable.changed(self) File "C:\Python25\Lib\site-packages\matplotlib\cm.py", line 174, in changed self.callbacksSM.process('changed', self) File "C:\Python25\Lib\site-packages\matplotlib\cbook.py", line 152, in process func(*args, **kwargs) File "C:\Python25\Lib\site-packages\matplotlib\figure.py", line 1028, in on_changed cb.update_bruteforce(m) File "C:\Python25\Lib\site-packages\matplotlib\colorbar.py", line 649, in update_bruteforce self.draw_all() File "C:\Python25\Lib\site-packages\matplotlib\colorbar.py", line 221, in draw_all self._process_values() File "C:\Python25\Lib\site-packages\matplotlib\colorbar.py", line 458, in _process_values b = self.norm.inverse(self._uniform_y(self.cmap.N+1)) File "C:\Python25\Lib\site-packages\matplotlib\colors.py", line 652, in inverse return vmin + val * (vmax - vmin) File "C:\Python25\Lib\site-packages\numpy\ma\core.py", line 1686, in __mul__ return multiply(self, other) File "C:\Python25\Lib\site-packages\numpy\ma\core.py", line 503, in __call__ result = self.f(d1, d2, *args, **kwargs).view(get_masked_subclass(a,b)) ValueError: shape mismatch: objects cannot be broadcast to a single shape UpdateSonarview works flawlessly if I modify the colormap (self.cmap) and call it then. If I modify self.norm and call UpdateSonarView I get this crash. Is it a bug from my bad usage of the lib? If not, I can perhaps send you a stripped down file showing the problem? Using matplotlib 0.98.1 under windows. Laurent - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] savefig and animated elements
Hi, I am trying to save figures where all the artists have animated = True. The result I get (I have tried svg and png formats) is a set of axes with labels, ticks, and grid, but no data points! I am using the WxAgg backend. Is this something to be expected, and if so, can anyone suggest a workaround? Thanks, Chee Sing Lee Oregon State University Dept. Nuclear Engineering and Radiation Health Physics - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] savefig and animated elements
Hi, I am trying to save figures where all the artists have animated = True. The result I get (I have tried svg and png formats) is a set of axes with labels, ticks, and grid, but no data points! I am using the WxAgg backend. Is this something to be expected, and if so, can anyone suggest a workaround? Thanks, Chee Sing Lee Oregon State University Dept. Nuclear Engineering and Radiation Health Physics - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] imshow update norm make my app crash.
On Tue, Jul 29, 2008 at 6:52 PM, Laurent Dufrechou <[EMAIL PROTECTED]> wrote: > I've applied the idea you've said later about colormap. > > Now I would like on an event to refresh my view so I've written this code: I would like to see what self.low_clutter_val = self.clutter_low.GetPosition() self.high_clutter_val = self.clutter_high.GetPosition() low and high clutter val are (can you print them, as well as their type, eg print low', type(self.low_clutter_val), self.low_clutter_val and likewise for the high val. From the error, it looks lik they are not scalars. JDH - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] matplotlib 0.98.3 release candidate, please test
On Tue, Jul 29, 2008 at 1:12 PM, John Hunter <[EMAIL PROTECTED]> wrote: > We are in the final stages of preparing a new matplotlib release, and > a lot of work has gone into it. If you would like to test the release > and see if it is working for you, that would be a big help > > http://matplotlib.sourceforge.net/tmp/matplotlib-0.98.3rc2.tar.gz > > Unfortunately, we do not have binary builds available at this time. Charlie was kind enough to build a windows installer for the release candidate for testing, which is available here http://matplotlib.sourceforge.net/tmp/matplotlib-0.98.3rc2.win32-py2.5.exe We aren't going to wait around for too long, so if you are able to test, please do so sooner rather than later. In the absence of serious problems, we'll be pushing out a release in the next day or two. JDH - This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users