SourceForge logo
SourceForge logo
Menu

matplotlib-devel

From: Ignat H. <ig...@gm...> - 2015年02月23日 13:53:46
Firstly I would like to apologize in case this should belong in the
matplotlib-users, I'm not sure if this is dev or users related.
Let us say we want to animate a 2D contour plot, then passing the blit =
True argument to FuncAnimation fails since the QuadContourSet has no axes
attribute.
Is it for some specific it is implemented like this? And maybe there a hack
to get this to work?
A working code example with the actually wanted one commented out.
import numpy as np
import matplotlib.animation as animation
from matplotlib import pyplot as plt
fig, ax = plt.subplots()
x = np.linspace( -np.pi, np.pi, 50 )
y = np.linspace( -np.pi, np.pi, 50 )
X, Y = np.meshgrid( x, y )
Z = np.zeros( X.shape )
def init():
 cont = ax.contourf( X, Y, Z )
 cbar = plt.colorbar( cont )
 return cont,
def animate( t ):
 k = np.array( [1,1] )
 omega = 0.5
 x = np.linspace( -np.pi, np.pi, 50 )
 y = np.linspace( -np.pi, np.pi, 50 )
 X, Y = np.meshgrid( x, y )
 Z = np.exp( 1j * (omega* t - X*k[0] ) ) * np.exp( - 1j * k[1]*Y )
 cont = ax.contourf( X, Y, Z )
 return cont,
#ani = animation.FuncAnimation( fig, animate, frames = 100, interval = 1,
repeat = False, blit = True, init_func = init,)
ani = animation.FuncAnimation( fig, animate, frames = 100, interval = 1,
repeat = False, init_func = init,)
plt.show()
From: Benjamin R. <ben...@ou...> - 2015年02月23日 16:43:46
Huh, how about that. ContourSet subclasses ScalarMappable, but not Artist.
I don't know if that is intentional or not, but given that most plotting
functions return artists, this would seem to be an anomaly. FuncAnimation
expects a list of Artists. Since QuadContourSet is (apparently) not an
Artist, then that is why it isn't working quite right.
As for blitting, I doubt you are going to need it here. Blitting is really
only advantagous if the computation/draw time of the animated portion is
comparable to the computation/draw time of the unanimated portion.
Contouring tends to be time-consuming (relatively speaking), so I doubt you
will gain much benefit from blitting it.
Ben Root
On Mon, Feb 23, 2015 at 8:53 AM, Ignat Harczuk <ig...@gm...> wrote:
> Firstly I would like to apologize in case this should belong in the
> matplotlib-users, I'm not sure if this is dev or users related.
>
>
> Let us say we want to animate a 2D contour plot, then passing the blit =
> True argument to FuncAnimation fails since the QuadContourSet has no axes
> attribute.
>
> Is it for some specific it is implemented like this? And maybe there a
> hack to get this to work?
>
> A working code example with the actually wanted one commented out.
>
> import numpy as np
> import matplotlib.animation as animation
> from matplotlib import pyplot as plt
>
> fig, ax = plt.subplots()
>
> x = np.linspace( -np.pi, np.pi, 50 )
> y = np.linspace( -np.pi, np.pi, 50 )
> X, Y = np.meshgrid( x, y )
> Z = np.zeros( X.shape )
>
> def init():
> cont = ax.contourf( X, Y, Z )
> cbar = plt.colorbar( cont )
> return cont,
>
> def animate( t ):
> k = np.array( [1,1] )
> omega = 0.5
>
> x = np.linspace( -np.pi, np.pi, 50 )
> y = np.linspace( -np.pi, np.pi, 50 )
> X, Y = np.meshgrid( x, y )
> Z = np.exp( 1j * (omega* t - X*k[0] ) ) * np.exp( - 1j * k[1]*Y )
> cont = ax.contourf( X, Y, Z )
> return cont,
>
> #ani = animation.FuncAnimation( fig, animate, frames = 100, interval = 1,
> repeat = False, blit = True, init_func = init,)
> ani = animation.FuncAnimation( fig, animate, frames = 100, interval = 1,
> repeat = False, init_func = init,)
> plt.show()
>
>
>
> ------------------------------------------------------------------------------
> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
> with Interactivity, Sharing, Native Excel Exports, App Integration & more
> Get technology previously reserved for billion-dollar corporations, FREE
>
> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
> _______________________________________________
> Matplotlib-devel mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
>
>
From: Thomas C. <tca...@gm...> - 2015年02月23日 23:06:53
This should probably be changed to use the new and improved container class
(along with error bar), but I should read the code to be sure.
On Mon, Feb 23, 2015, 11:44 Benjamin Root <ben...@ou...> wrote:
> Huh, how about that. ContourSet subclasses ScalarMappable, but not Artist.
> I don't know if that is intentional or not, but given that most plotting
> functions return artists, this would seem to be an anomaly. FuncAnimation
> expects a list of Artists. Since QuadContourSet is (apparently) not an
> Artist, then that is why it isn't working quite right.
>
> As for blitting, I doubt you are going to need it here. Blitting is really
> only advantagous if the computation/draw time of the animated portion is
> comparable to the computation/draw time of the unanimated portion.
> Contouring tends to be time-consuming (relatively speaking), so I doubt you
> will gain much benefit from blitting it.
>
> Ben Root
>
> On Mon, Feb 23, 2015 at 8:53 AM, Ignat Harczuk <ig...@gm...> wrote:
>
>> Firstly I would like to apologize in case this should belong in the
>> matplotlib-users, I'm not sure if this is dev or users related.
>>
>>
>> Let us say we want to animate a 2D contour plot, then passing the blit =
>> True argument to FuncAnimation fails since the QuadContourSet has no axes
>> attribute.
>>
>> Is it for some specific it is implemented like this? And maybe there a
>> hack to get this to work?
>>
>> A working code example with the actually wanted one commented out.
>>
>> import numpy as np
>> import matplotlib.animation as animation
>> from matplotlib import pyplot as plt
>>
>> fig, ax = plt.subplots()
>>
>> x = np.linspace( -np.pi, np.pi, 50 )
>> y = np.linspace( -np.pi, np.pi, 50 )
>> X, Y = np.meshgrid( x, y )
>> Z = np.zeros( X.shape )
>>
>> def init():
>> cont = ax.contourf( X, Y, Z )
>> cbar = plt.colorbar( cont )
>> return cont,
>>
>> def animate( t ):
>> k = np.array( [1,1] )
>> omega = 0.5
>>
>> x = np.linspace( -np.pi, np.pi, 50 )
>> y = np.linspace( -np.pi, np.pi, 50 )
>> X, Y = np.meshgrid( x, y )
>> Z = np.exp( 1j * (omega* t - X*k[0] ) ) * np.exp( - 1j * k[1]*Y )
>> cont = ax.contourf( X, Y, Z )
>> return cont,
>>
>> #ani = animation.FuncAnimation( fig, animate, frames = 100, interval = 1,
>> repeat = False, blit = True, init_func = init,)
>> ani = animation.FuncAnimation( fig, animate, frames = 100, interval = 1,
>> repeat = False, init_func = init,)
>> plt.show()
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
>> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
>> with Interactivity, Sharing, Native Excel Exports, App Integration & more
>> Get technology previously reserved for billion-dollar corporations, FREE
>>
>> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Matplotlib-devel mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
>>
>>
> ------------------------------------------------------------
> ------------------
> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
> with Interactivity, Sharing, Native Excel Exports, App Integration & more
> Get technology previously reserved for billion-dollar corporations, FREE
> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&
> iu=/4140/ostg.clktrk_______________________________________________
> Matplotlib-devel mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
>
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 によって変換されたページ (->オリジナル) /