Skip to content
Advertisement

Animating two circles Python

I have a text file, with the coordinates of two circles on it. I want to produce a live animation of both particles. For some reason the following code crashes

JavaScript

The text file that the data is taken from has the columns of X1, Y1, X2 and Y2 where X1 represents the x coordinate of the 1st particle etc.

If I remove all references to the second particle, it works and fully displays the first. Any help would be appreciated.

An example of the text file is the following:

JavaScript

(The latter columns arent used in this code) and the exact error message is ‘AttributeError: ‘NoneType’ object has no attribute ‘_get_view”.

Thank you

Advertisement

Answer

The code crashes because you “mixed” matplotlib’s “pyplot” and “object-oriented” approaches in a wrong way. Here is the working code. Note that I created ax, the axes in which artists are going to be added. On this axes I also applied the axis limits.

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement