Animation.save does not save all frames in matplotlib

时间:2017-08-30 20:18:24

标签: python animation matplotlib

I have the following code to animate plot:

userId

public class ClientList extends AppCompatActivity { String userId; FirebaseAuth mAuth; FirebaseUser firebaseUser; DatabaseReference databaseRef; String clientAddress; String clientPhone; ListView myClientList; List<String> clientArrayList; // 1. Add AuthStateListener private FirebaseAuth.AuthStateListener mAuthListener; // 3.add and remove AuthStateListener on Activity's onStart and onStop respectively @Override protected void onStart() { super.onStart(); mAuth.addAuthStateListener(mAuthListener); } @Override protected void onStop() { super.onStop(); mAuth.removeAuthStateListener(mAuthListener); } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_client_list); mAuth = FirebaseAuth.getInstance(); // 2. Init the AuthStateListener mAuthListener = new FirebaseAuth.AuthStateListener() { @Override public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) { /* Everytime a user is signed in/out, this will be called. (Including when the activity launches) */ if (firebaseAuth.getCurrentUser() != null) { // User signed in, now get client-list getClientList(); } else { /* No user signed in, First sign in. After having signed in, again this method will be called (since the auth-state has changed). Then the if-case runs and getClientList() is called */ mAuth.signInWithEmailAndPassword("user_email", "user_password"); } } }; } function yields data and var popUpCookie = "getCookie"; if(!popUpCookie){ var newWin = window.open("http://www.example.com"); if(!newWin || newWin.closed || typeof newWin.closed=='undefined') { //POPUP BLOCKED - Create Cookie }else{ //POPUP NOT BLOCKED - Create Cookie } } function set this data onto the plot.

When I run this script with # Creating the Animation object line_ani = animation.FuncAnimation(fig, update, frames=generate(), fargs=(lines,), interval=5, blit=False) #plt.show() line_ani.save("animation.mp4") I see very slow and long animation.

When I run this script with generate it ends very soon and produces very short animation inside update file.

Why and how to fix?

UPDATE

Although script runs without any errors, PyCharms is reporting a warning:

enter image description here

Expected type 'Optional[int]', got 'Generator[...

0 个答案:

没有答案