How do I animate circles and line with matplotlib?
up vote
0
down vote
favorite
I can animate six circles, and I can animate a line. When I try to animate both, I cannot figure out what init() and animate() should return. For six circles I "return tuple(pins)" and for the line I "return line,". Each pin is a "class 'matplotlib.patches.Circle'" and the line is "class 'matplotlib.lines.Line2D'."
When I try to animate both the circles and the line, I have tried many different return statements without success. Here are the some of the results:
return line, tuple(pins) GIVES 'tuple' object has no attribute 'set_animated'
return tuple(pins) + (line) GIVES can only concatenate tuple (not "Line2D") to tuple
return tuple(pins) + tuple(line) GIVES 'Line2D' object is not iterable
animation matplotlib
add a comment |
up vote
0
down vote
favorite
I can animate six circles, and I can animate a line. When I try to animate both, I cannot figure out what init() and animate() should return. For six circles I "return tuple(pins)" and for the line I "return line,". Each pin is a "class 'matplotlib.patches.Circle'" and the line is "class 'matplotlib.lines.Line2D'."
When I try to animate both the circles and the line, I have tried many different return statements without success. Here are the some of the results:
return line, tuple(pins) GIVES 'tuple' object has no attribute 'set_animated'
return tuple(pins) + (line) GIVES can only concatenate tuple (not "Line2D") to tuple
return tuple(pins) + tuple(line) GIVES 'Line2D' object is not iterable
animation matplotlib
provide a Minimal, Complete, and Verifiable example
– eyllanesc
Nov 14 at 6:01
You say whatpin
is, but not whatpins
is.
– ImportanceOfBeingErnest
Nov 14 at 9:49
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I can animate six circles, and I can animate a line. When I try to animate both, I cannot figure out what init() and animate() should return. For six circles I "return tuple(pins)" and for the line I "return line,". Each pin is a "class 'matplotlib.patches.Circle'" and the line is "class 'matplotlib.lines.Line2D'."
When I try to animate both the circles and the line, I have tried many different return statements without success. Here are the some of the results:
return line, tuple(pins) GIVES 'tuple' object has no attribute 'set_animated'
return tuple(pins) + (line) GIVES can only concatenate tuple (not "Line2D") to tuple
return tuple(pins) + tuple(line) GIVES 'Line2D' object is not iterable
animation matplotlib
I can animate six circles, and I can animate a line. When I try to animate both, I cannot figure out what init() and animate() should return. For six circles I "return tuple(pins)" and for the line I "return line,". Each pin is a "class 'matplotlib.patches.Circle'" and the line is "class 'matplotlib.lines.Line2D'."
When I try to animate both the circles and the line, I have tried many different return statements without success. Here are the some of the results:
return line, tuple(pins) GIVES 'tuple' object has no attribute 'set_animated'
return tuple(pins) + (line) GIVES can only concatenate tuple (not "Line2D") to tuple
return tuple(pins) + tuple(line) GIVES 'Line2D' object is not iterable
animation matplotlib
animation matplotlib
edited Nov 14 at 5:58
asked Nov 14 at 5:50
user3286261
36127
36127
provide a Minimal, Complete, and Verifiable example
– eyllanesc
Nov 14 at 6:01
You say whatpin
is, but not whatpins
is.
– ImportanceOfBeingErnest
Nov 14 at 9:49
add a comment |
provide a Minimal, Complete, and Verifiable example
– eyllanesc
Nov 14 at 6:01
You say whatpin
is, but not whatpins
is.
– ImportanceOfBeingErnest
Nov 14 at 9:49
provide a Minimal, Complete, and Verifiable example
– eyllanesc
Nov 14 at 6:01
provide a Minimal, Complete, and Verifiable example
– eyllanesc
Nov 14 at 6:01
You say what
pin
is, but not what pins
is.– ImportanceOfBeingErnest
Nov 14 at 9:49
You say what
pin
is, but not what pins
is.– ImportanceOfBeingErnest
Nov 14 at 9:49
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
Note that you only need to return something from the animating function if you use blitting.
From the documentation:
If
blit == True
, func must return an iterable of all artists that were modified or created. This information is used by the blitting algorithm to determine which parts of the figure have to be updated. The return value is unused ifblit == False
and may be omitted in that case.
So just ommiting the return
altogether may be the easiest option.
If you need/want to use blitting, you need to return an iterable of artists. This can e.g. be a tuple or a list. Unfortunately, it's not clear what pins
is from the question.
Supposing pins
is a list,
return pins + [line]
or if you want to make it a list,
return list(pins) + [line]
Supposing pins
is a tuple,
return pins + (line,)
or if you want to make it a tuple,
return tuple(pins) + (line,)
Removing blit from anim worked. Since pins is a list so did adding a line list. Making a tuple, for reasons I no longer remember, was the cause of my problem because I was not handling the tuple correctly. Thank you very much.
– user3286261
Nov 14 at 17:33
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
Note that you only need to return something from the animating function if you use blitting.
From the documentation:
If
blit == True
, func must return an iterable of all artists that were modified or created. This information is used by the blitting algorithm to determine which parts of the figure have to be updated. The return value is unused ifblit == False
and may be omitted in that case.
So just ommiting the return
altogether may be the easiest option.
If you need/want to use blitting, you need to return an iterable of artists. This can e.g. be a tuple or a list. Unfortunately, it's not clear what pins
is from the question.
Supposing pins
is a list,
return pins + [line]
or if you want to make it a list,
return list(pins) + [line]
Supposing pins
is a tuple,
return pins + (line,)
or if you want to make it a tuple,
return tuple(pins) + (line,)
Removing blit from anim worked. Since pins is a list so did adding a line list. Making a tuple, for reasons I no longer remember, was the cause of my problem because I was not handling the tuple correctly. Thank you very much.
– user3286261
Nov 14 at 17:33
add a comment |
up vote
1
down vote
accepted
Note that you only need to return something from the animating function if you use blitting.
From the documentation:
If
blit == True
, func must return an iterable of all artists that were modified or created. This information is used by the blitting algorithm to determine which parts of the figure have to be updated. The return value is unused ifblit == False
and may be omitted in that case.
So just ommiting the return
altogether may be the easiest option.
If you need/want to use blitting, you need to return an iterable of artists. This can e.g. be a tuple or a list. Unfortunately, it's not clear what pins
is from the question.
Supposing pins
is a list,
return pins + [line]
or if you want to make it a list,
return list(pins) + [line]
Supposing pins
is a tuple,
return pins + (line,)
or if you want to make it a tuple,
return tuple(pins) + (line,)
Removing blit from anim worked. Since pins is a list so did adding a line list. Making a tuple, for reasons I no longer remember, was the cause of my problem because I was not handling the tuple correctly. Thank you very much.
– user3286261
Nov 14 at 17:33
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
Note that you only need to return something from the animating function if you use blitting.
From the documentation:
If
blit == True
, func must return an iterable of all artists that were modified or created. This information is used by the blitting algorithm to determine which parts of the figure have to be updated. The return value is unused ifblit == False
and may be omitted in that case.
So just ommiting the return
altogether may be the easiest option.
If you need/want to use blitting, you need to return an iterable of artists. This can e.g. be a tuple or a list. Unfortunately, it's not clear what pins
is from the question.
Supposing pins
is a list,
return pins + [line]
or if you want to make it a list,
return list(pins) + [line]
Supposing pins
is a tuple,
return pins + (line,)
or if you want to make it a tuple,
return tuple(pins) + (line,)
Note that you only need to return something from the animating function if you use blitting.
From the documentation:
If
blit == True
, func must return an iterable of all artists that were modified or created. This information is used by the blitting algorithm to determine which parts of the figure have to be updated. The return value is unused ifblit == False
and may be omitted in that case.
So just ommiting the return
altogether may be the easiest option.
If you need/want to use blitting, you need to return an iterable of artists. This can e.g. be a tuple or a list. Unfortunately, it's not clear what pins
is from the question.
Supposing pins
is a list,
return pins + [line]
or if you want to make it a list,
return list(pins) + [line]
Supposing pins
is a tuple,
return pins + (line,)
or if you want to make it a tuple,
return tuple(pins) + (line,)
answered Nov 14 at 9:58
ImportanceOfBeingErnest
121k10124196
121k10124196
Removing blit from anim worked. Since pins is a list so did adding a line list. Making a tuple, for reasons I no longer remember, was the cause of my problem because I was not handling the tuple correctly. Thank you very much.
– user3286261
Nov 14 at 17:33
add a comment |
Removing blit from anim worked. Since pins is a list so did adding a line list. Making a tuple, for reasons I no longer remember, was the cause of my problem because I was not handling the tuple correctly. Thank you very much.
– user3286261
Nov 14 at 17:33
Removing blit from anim worked. Since pins is a list so did adding a line list. Making a tuple, for reasons I no longer remember, was the cause of my problem because I was not handling the tuple correctly. Thank you very much.
– user3286261
Nov 14 at 17:33
Removing blit from anim worked. Since pins is a list so did adding a line list. Making a tuple, for reasons I no longer remember, was the cause of my problem because I was not handling the tuple correctly. Thank you very much.
– user3286261
Nov 14 at 17:33
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53293911%2fhow-do-i-animate-circles-and-line-with-matplotlib%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
provide a Minimal, Complete, and Verifiable example
– eyllanesc
Nov 14 at 6:01
You say what
pin
is, but not whatpins
is.– ImportanceOfBeingErnest
Nov 14 at 9:49