Well I have narrowed down exactly what causes it and produced a
stripped down piece of code that reproduces the effect.
It is related to events. I use mpl_connect to connect two functions
#1 onpick - when a plot is picked annotate plot (in practice IF it is
a binary array then annotate)
#2 onpress - click anywhere else and it clears said annotation.
Works well (probably not the best way todo this, but it works). Thing
is it seems my onpress method is called when I click on the save on
I guess I should add an if statement ( if event.inaxis ...) so that
the remove method isn't called outside of the axes area
from matplotlib.pyplot import figure, show
import numpy as np
fig = figure()
text = None
x = np.arange(0,10,0.2)
y = np.arange(10,20,0.2)
ax = fig.add_subplot(111)
x = event.artist.get_xdata()[event.ind]
y = event.artist.get_ydata()[event.ind]
text = ax.annotate('foo',xy=(x,y),xytext=(0.8,
On 6 September 2012 14:55, Jon Roadley-Battin <jon.roadleybattin@...287...> wrote:
On 6 September 2012 14:20, Benjamin Root <ben.root@...1304...> wrote:
On Thu, Sep 6, 2012 at 5:29 AM, Jon Roadley-Battin >> <jon.roadleybattin@...287...> wrote:
I have an odd problem with saving plot images via the navigation bar
(unsure if it is unique to the navigation bar) if I have added custom
I have a python gui which is used to connect to some hardware as a
diagnosis tool. Its a pyGTK program and on one ui tab there is an
embeded matplotlib plot.
Now some of the signals I plot rather than being a waveform is more of
a collection of flags (16bit but thats a by and by)
0 = fault1
0 = fault2
1 = fault3
0 = fault4
so for this I can plot this and it will show 2 (possibly changing w.r.t.
I then hook in via a onpick event such that if I click on a plot I
essentially do this:
ie I put a cross where someone clicked (for indication) and I also
create a texxbox which lists human readable version of what bits are
Great, really helpful in debugging.
The issue is if you click on the save image icon on the navigation
toolbar it saves the waveform and legend BUT not the additional
content (the cross and the textbox).
any idea as to how todo this?
What you are describing should work as expected. Is it possible that you
could make a simple, self-contained version (hopefully it doesn't need to be
embedded to reproduce the problem)? Maybe a modification of one of the
existing examples in the online docs might be able to reproduce your issue?
I agree it should work and the examples i have run allow this so this
is why I am looking over my specifics.
The only thing I can see is the examples call to add txt via an axes
entity, I have been doing it via a figure entity.
I am going to re-write to draw on the axis (last time I did this it
didn't display hence going for a figure).
If this doesn't work I shall strip the code down to a minimum example
demonstrating what I am describing