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

Appearance settings

Widget and animation improvements #3985

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 13, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Turn off blitting and improve RadioButton
  • Loading branch information
WeatherGod committed Jan 8, 2015
commit a5fccbc7bf02c20401e405cb9a8eeec7c7afd47c
4 changes: 2 additions & 2 deletions 4 examples/animation/animate_decay.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def data_gen(t=0):
cnt = 0
while cnt < 1000:
cnt += 1
t += 0.05
t += 0.1
yield t, np.sin(2*np.pi*t) * np.exp(-t/10.)

fig, ax = plt.subplots()
Expand All @@ -32,6 +32,6 @@ def run(data):

return line,

ani = animation.FuncAnimation(fig, run, data_gen, blit=True, interval=10,
ani = animation.FuncAnimation(fig, run, data_gen, blit=False, interval=10,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why turn off blitting?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the animation goes on, the limits keep changing. When blitting is turned
on, you don't see the x-axis change, which is incorrect. Turn blitting off,
and you see the scale change correctly.

On Thu, Jan 8, 2015 at 10:12 PM, Thomas A Caswell notifications@github.com
wrote:

In examples/animation/animate_decay.py
#3985 (diff)
:

@@ -32,6 +32,6 @@ def run(data):

 return line,

-ani = animation.FuncAnimation(fig, run, data_gen, blit=True, interval=10,
+ani = animation.FuncAnimation(fig, run, data_gen, blit=False, interval=10,

why turn of


Reply to this email directly or view it on GitHub
https://github.com/matplotlib/matplotlib/pull/3985/files#r22699612.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, ok. If you move the mouse in and out it triggers a full re-draw (at least on qt) which updates them so I thought it was always updating correctly.

There probably should be some logic someplace in the animation that if any has change to do a full-redraw.

This actually ties back into what @efiring and I were talking about to make pyplot behave better as well as it wouldn't be too hard to co-op that system to allow non-animated artists to make the axes as 'dirty' which would trigger a full-redraw.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't need to do that. The animation module already attaches a reset of
the blit to frame resizes, we just never attached it to other kinds of
changes.

I don't know why it doesn't make a difference for you though. A full redraw
isn't sufficient. The bbox copy has to be reset.
On Jan 8, 2015 10:32 PM, "Thomas A Caswell" notifications@github.com
wrote:

In examples/animation/animate_decay.py
#3985 (diff)
:

@@ -32,6 +32,6 @@ def run(data):

 return line,

-ani = animation.FuncAnimation(fig, run, data_gen, blit=True, interval=10,
+ani = animation.FuncAnimation(fig, run, data_gen, blit=False, interval=10,

ah, ok. If you move the mouse in and out it triggers a full re-draw (at
least on qt) which updates them so I thought it was always updating
correctly.

There probably should be some logic someplace in the animation that if any
has change to do a full-redraw.

This actually ties back into what @efiring https://github.com/efiring
and I were talking about to make pyplot behave better as well as it
wouldn't be too hard to co-op that system to allow non-animated artists to
make the axes as 'dirty' which would trigger a full-redraw.


Reply to this email directly or view it on GitHub
https://github.com/matplotlib/matplotlib/pull/3985/files#r22700042.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought that the animation code added hooks so that on a redraw event it takes care of re-copying the blit box not to resizes spcefically.

What is going on on my system (I think) is that when you mouse in/out qt triggers a full re-paint (as there may have been silly alpha stuff going on when the window was non-focused (oh, right I also use focus follow mouse so I am really changing the focus state) ) and that repaint from the windowing system bubbles down and does a full re-draw of the canvas which updates the tick labels.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That might be the case. It was a long time ago that Ryan and I worked on
that part. If that is the case, then a focus-follows-mouse setup would
trigger a redraw and thus reset the blit. In any case, let's focus on the
other questions for this PR: 1) should we use indexes or string labels and
2) should the check button's set_active() allow for explicit setting of the
state rather than strictly toggling?

On Thu, Jan 8, 2015 at 11:11 PM, Thomas A Caswell notifications@github.com
wrote:

In examples/animation/animate_decay.py
#3985 (diff)
:

@@ -32,6 +32,6 @@ def run(data):

 return line,

-ani = animation.FuncAnimation(fig, run, data_gen, blit=True, interval=10,
+ani = animation.FuncAnimation(fig, run, data_gen, blit=False, interval=10,

I thought that the animation code added hooks so that on a redraw event it
takes care of re-copying the blit box not to resizes spcefically.

What is going on on my system (I think) is that when you mouse in/out qt
triggers a full re-paint (as there may have been silly alpha stuff going on
when the window was non-focused (oh, right I also use focus follow mouse so
I am really changing the focus state) ) and that repaint from the windowing
system bubbles down and does a full re-draw of the canvas which updates the
tick labels.


Reply to this email directly or view it on GitHub
https://github.com/matplotlib/matplotlib/pull/3985/files#r22700791.

repeat=False)
plt.show()
27 changes: 20 additions & 7 deletions 27 lib/matplotlib/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -698,17 +698,30 @@ def inside(p):
pcirc = np.array([p.center[0], p.center[1]])
return dist(pclicked, pcirc) < p.radius

for p, t in zip(self.circles, self.labels):
for i, (p, t) in enumerate(zip(self.circles, self.labels)):
if t.get_window_extent().contains(event.x, event.y) or inside(p):
inp = p
thist = t
self.value_selected = t.get_text()
index_match = i
break
else:
return

for p in self.circles:
if p == inp:
self.set_active(index_match)

def set_active(self, index):
"""
Trigger which radio button to make active.

*index* is an index into the original label list
that this object was constructed with.

"""
if 0 > index >= len(self.labels):
raise ValueError("Invalid RadioButton index: %d" % index)

self.value_selected = self.labels[index].get_text()

for i, p in enumerate(self.circles):
if i == index:
color = self.activecolor
else:
color = self.ax.get_axis_bgcolor()
Expand All @@ -720,7 +733,7 @@ def inside(p):
if not self.eventson:
return
for cid, func in six.iteritems(self.observers):
func(thist.get_text())
func(self.labels[index].get_text())

def on_clicked(self, func):
"""
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.