Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

'QuadContourSet' object has no attribute 'set_visible' or 'set_animated' #6139

Closed
Milestone
@fabrivelas

Description

@fabrivelas

matplotlib/1.5.1
python3/3.5.1
osx 10.11.3
Installation using homebrew.

The following code gives me an error 'QuadContourSet' object has no attribute 'set_visible'
I added a workaround (http://stackoverflow.com/questions/23070305/how-can-i-make-an-animation-with-contourf) and it worked for version 1.3.1 of matplotlib but with matplotlib version 1.5.1 I get the error 'QuadContourSet' object has no attribute 'set_animated'. Adding extra code similar to that for 'set_visible' makes the code work again.
I would expect the code to work without the Bug fix code snippets included.

#! coding=utf-8import matplotlib.pyplot as pltimport matplotlib.animation as animationimport numpy as npimport types################################################################### Bug fix for Quad Contour set not having attribute 'set_visible'def setvisible(self,vis):    for c in self.collections: c.set_visible(vis)def setanimated(self,ani):    for c in self.collections: c.set_animated(ani)####################################################################fig = plt.figure()# Some 2D geo arrays to plot (time,lat,lon)data = np.random.random_sample((20,90,360))lat = range(len(data[0,:,0]))lon = range(len(data[0,0,:]))lons,lats = np.meshgrid(lon,lat)# ims is a list of lists, each row is a list of artists to draw in the# current frame; here we are animating three artists, the image and 2 # annotatons (title), in each frameims = []for i in range(len(data[:,0,0])):    t_step = int(i)    im = plt.contourf(lons,lats,data[i,:,:])    text = 'title=' + str(i)    te = plt.text(90,90,str(text))    an = plt.annotate(str(text), xy=(0.45, 1.05), xycoords='axes fraction')    #################################################################    ## Bug fix for Quad Contour set not having the attributes    ## 'set_visible' and 'set_animated'    # ** uncomment the following 2 lines to make the code work:**#   im.set_visible = types.MethodType(setvisible,im)#   im.set_animated = types.MethodType(setanimated,im)    im.axes = plt.gca()    im.figure = fig    ####################################################################    ims.append([im,te,an])#ani = animation.ArtistAnimation(fig, ims, interval=70,repeat_delay=1000, blit=False)ani = animation.ArtistAnimation(fig, ims)## For saving the animation we need ffmpeg binary:#FFwriter = animation.FFMpegWriter()#ani.save('basic_animation.mp4', writer = FFwriter)plt.show()

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp