Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions 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()
55 changes: 42 additions & 13 deletions lib/matplotlib/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,24 +569,39 @@ def _clicked(self, event):
if event.inaxes != self.ax:
return

for p, t, lines in zip(self.rectangles, self.labels, self.lines):
for i, (p, t) in enumerate(zip(self.rectangles, self.labels)):
if (t.get_window_extent().contains(event.x, event.y) or
p.get_window_extent().contains(event.x, event.y)):
l1, l2 = lines
l1.set_visible(not l1.get_visible())
l2.set_visible(not l2.get_visible())
thist = t
self.set_active(i)
break
else:
return

def set_active(self, index):
"""
Directly (de)activate a check button by index.

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

Callbacks will be triggered if :attr:`eventson` is True.

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

l1, l2 = self.lines[index]
Copy link
Member

Choose a reason for hiding this comment

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

super picky, would this be clearer as

for ln is self.lines[index]:
    ln.set_visible(not ln.get_visible())

l1.set_visible(not l1.get_visible())
l2.set_visible(not l2.get_visible())

if self.drawon:
self.ax.figure.canvas.draw()

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 Expand Up @@ -698,17 +713,31 @@ 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()
self.set_active(i)
break
else:
return

for p in self.circles:
if p == inp:
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.
Raise ValueError if the index is invalid.

Callbacks will be triggered if :attr:`eventson` is True.

"""
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 +749,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