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

Reply via email to