0

I am using matplotlib.animation to animate changes in position of multiple points over time on matplotlib.Basemap map.

I have got it working for me for basic points, but I have been trying to plot the points as images, let's say a enter image description here (like was explained here) and include a legend which displays the day count for each day being plotted.

When I attempt to plot the points as images, I get the following error:

AttributeError: 'AnnotationBbox' object has no attribute 'set_data'

How does one set the data for such an object?

Community
  • 1
  • 1
ryanjdillon
  • 17,658
  • 9
  • 85
  • 110

1 Answers1

1

After creating the annotation object:

image = np.array(Image.open(img_filename))
im = OffsetImage(image, zoom=1)
ab = AnnotationBbox(im, (x, y), xycoords='data', frameon=False)

I ran a dir(ab) to find what attributes the object had. It appears the correct attribute to set the position data for an annotation box is xytext, which can be set by doing the following:

ab.xytext = (new_x, new_y)

I am attempting to do this with a list of images, so now I am receiving the error AttributeError: 'list' object has no attribute 'axes' when returning the list of annotation boxes from init() and animate(i), which I will follow up on in another question.

ryanjdillon
  • 17,658
  • 9
  • 85
  • 110