SourceForge logo
SourceForge logo
Menu

matplotlib-users

From: Mads I. <mad...@gm...> - 2012年06月28日 07:12:49
Hi,
Suppose you do this:
axes = self.figure().get_axes()
contour = axes.contourf(x,y,z)
colorbar = self.figure().colorbar(contour)
Suppose that the contour data changes, can you update the colorbar with 
the new data?
Currently I remove the colorbar and insert a new one - but I have a 
feeling that something smarter could be done.
Best regards,
Mads
-- 
+-----------------------------------------------------+
| Mads Ipsen |
+----------------------+------------------------------+
| Gåsebæksvej 7, 4. tv | |
| DK-2500 Valby | phone: +45-29716388 |
| Denmark | email: mad...@gm... |
+----------------------+------------------------------+
From: Benjamin R. <ben...@ou...> - 2012年07月02日 18:26:18
Mads,
On Thu, Jun 28, 2012 at 3:12 AM, Mads Ipsen <mad...@gm...> wrote:
> Hi,
>
> Suppose you do this:
>
> axes = self.figure().get_axes()
> contour = axes.contourf(x,y,z)
> colorbar = self.figure().colorbar(contour)
>
> Suppose that the contour data changes, can you update the colorbar with
> the new data?
>
> Currently I remove the colorbar and insert a new one - but I have a
> feeling that something smarter could be done.
>
> Best regards,
>
> Mads
>
The only way I could think of to do what you want a bit more intelligently
is to reuse the existing QuadContourMesh that comes from the initial call
to contourf. Updates to that "ScalarMappable" object should then trigger
updates to the existing colorbar. Not entirely sure which code would be
cleaner, though, because reusing a QuadContourMesh isn't easy.
Cheers!
Ben Root
From: Eric F. <ef...@ha...> - 2012年07月02日 18:59:51
On 06/27/2012 09:12 PM, Mads Ipsen wrote:
> Hi,
>
> Suppose you do this:
>
> axes = self.figure().get_axes()
> contour = axes.contourf(x,y,z)
> colorbar = self.figure().colorbar(contour)
>
> Suppose that the contour data changes, can you update the colorbar with
> the new data?
>
> Currently I remove the colorbar and insert a new one - but I have a
> feeling that something smarter could be done.
When you say "the contour data changes", I assume you mean you are 
contouring a new set of data, with new contour levels, and not just 
changing the cmap. In this case there is no point in trying to save 
something from the old colorbar, so remaking it is the right thing to 
do. Simple, effective, foolproof. (If only the cmap is changed, then 
the existing colorbar should be getting updated automatically.)
Eric
>
> Best regards,
>
> Mads
>
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /