Annotate Behaviour - Arrows Missing

Ubuntu Karmic
matplotlib from repository
Python 2.6.4 (r264:75706, Dec 7 2009, 18:45:15)
[GCC 4.4.1] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.

import matplotlib as mpl
mpl.version
‘0.99.0’

Running the leach_kinetics.py script and annotating the graph should display two annotations indicating the position of relevant phenomena. However, attached are two outputs, 1) as_script.pdf shows the output of the script (note the missing annotations) and 2) a panned image showing the presence of the annotation when the origin is moved into the visible area of the axes.

There seems to be some strange clipping behaviour (not too sure if that is the correct term) with respect the the drawing (or not) of the arrow. It appears that if the arrow begins or ends on the axes then it is not drawn. Verification of this and tips for a matplotlib tweak to prevent it from happening would also be appreciated?

Kind Regards,

Kurt

as_script.pdf (55.5 KB)

leach_kinetics.py (2.98 KB)

panned_to_show_0_0.pdf (55.7 KB)

···

If It Exists, You’ll Find it on SEEK Shopping Trolley Mechanic

This is the feature that is not properly documented.
You should call annotate with optional keyword

        annotation_clip=False,

See below for the details.

http://matplotlib.sourceforge.net/api/artist_api.html?highlight=annotation#matplotlib.text.Annotation.set_annotation_clip

I'll fix the documentation.
Regards,

-JJ

···

On Mon, Jan 18, 2010 at 6:19 PM, Kurt Forrester <kurtforrester@...32...> wrote:

Ubuntu Karmic
matplotlib from repository
Python 2.6.4 (r264:75706, Dec 7 2009, 18:45:15)
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import matplotlib as mpl
mpl.__version__

'0.99.0'

Running the leach_kinetics.py script and annotating the graph should display
two annotations indicating the position of relevant phenomena. However,
attached are two outputs, 1) as_script.pdf shows the output of the script
(note the missing annotations) and 2) a panned image showing the presence of
the annotation when the origin is moved into the visible area of the axes.

There seems to be some strange clipping behaviour (not too sure if that is
the correct term) with respect the the drawing (or not) of the arrow. It
appears that if the arrow begins or ends on the axes then it is not drawn.
Verification of this and tips for a matplotlib tweak to prevent it from
happening would also be appreciated?

Kind Regards,

Kurt

________________________________
If It Exists, You'll Find it on SEEK Shopping Trolley Mechanic
------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for
Conference
attendees to learn about information security's most important issues
through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

JJ thanks for the tip unfortunately there was no change.

I modified the script for the hax. annotate(…) to include the annotate_clip=False, however there is no change in the behaviour of the arrows. They are not visible until the xy=(a,b) have values for “a” and “b” that are both greater than their respective origin values (0,0), otherwise they remain clipped. I tested this by replacing the “true” value with (1.0e-10,1.0e-10) resulting in the arrow becoming visible. This is a feasible work around for this instance but it may not suit all applications.

Is anybody else experiencing the same issue? Is there another setting that I my tweak to overcome this?

Kind Regards,

Kurt

···

From: lee.j.joon@…1003…7…
Date: Mon, 18 Jan 2010 19:18:31 -0500
Subject: Re: [Matplotlib-users] Annotate Behaviour - Arrows Missing
To: kurtforrester@…32…
CC: matplotlib-users@lists.sourceforge.net

This is the feature that is not properly documented.
You should call annotate with optional keyword

annotation_clip=False,

See below for the details.

http://matplotlib.sourceforge.net/api/artist_api.html?highlight=annotation#matplotlib.text.Annotation.set_annotation_clip

I’ll fix the documentation.
Regards,

-JJ

On Mon, Jan 18, 2010 at 6:19 PM, Kurt Forrester > <kurtforrester@…32…> wrote:

Ubuntu Karmic
matplotlib from repository
Python 2.6.4 (r264:75706, Dec 7 2009, 18:45:15)
[GCC 4.4.1] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.

import matplotlib as mpl
mpl.version
‘0.99.0’

Running the leach_kinetics.py script and annotating the graph should display
two annotations indicating the position of relevant phenomena. However,
attached are two outputs, 1) as_script.pdf shows the output of the script
(note the missing annotations) and 2) a panned image showing the presence of
the annotation when the origin is moved into the visible area of the axes.

There seems to be some strange clipping behaviour (not too sure if that is
the correct term) with respect the the drawing (or not) of the arrow. It
appears that if the arrow begins or ends on the axes then it is not drawn.
Verification of this and tips for a matplotlib tweak to prevent it from
happening would also be appreciated?

Kind Regards,

Kurt


If It Exists, You’ll Find it on SEEK Shopping Trolley Mechanic

Throughout its 18-year history, RSA Conference consistently attracts the
world’s best and brightest in the field, creating opportunities for
Conference
attendees to learn about information security’s most important issues
through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev


Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options


Learn how Video chat with Windows Live Messenger

It should be "annotation_clip" not "annotate_clip", but it may be just a typo.

Anyhow, as far as I know (as I wrote the related code), there is no
other setting. And your script work fine for me when "annotation_clip"
parameter is added. While I'm testing this with the current svn
version of matplolib, I don't think I see any bug fix related with
this after 0.99.0 release.

Anyhow, It would be great if you can install the newest version of
matplotlib (0.99.1 or even svn) and see if arrows are still missing.

Regards,

-JJ

···

On Tue, Jan 19, 2010 at 2:48 AM, Kurt Forrester <kurtforrester@...32...> wrote:

I modified the script for the hax. annotate(...) to include the
annotate_clip=False, however there is no change in the behaviour of the
arrows.

JJ,

Indeed it is a typo in the email and not in the script. I have used “annotation_clip” with no result.

Additional information that I forgot to supply was that on python 2.5/windows/matplotlib 0.98.xxx (my work machine, not accessible at the moment for the subversion number) this worked fine and there may have been a regression from this to the current 0.99.0 (in the ubuntu repository).

I tried to build and install the 0.99.1 but need to profess my noobness as I an unsure as to how to get the build, which built without errors, to be installed on ubuntu as I performed the prescribed “python setup.py build” then “sudo python setup.py install” without error. However, when python is loaded/run/booted it still is looking at 0.99.0. The thing I noticed was that instead on installing in site-packages it installed in dist-package (or something like) location and I guess there is something in the python path that needs redirecting. I usually use .deb and dpkg to work out the “appropriate” place for such things (former windows user). I am not familiar with the flags to pass to the python setup script to get it to install all the build files/folders to an alternate location (presumably the correct location). If I could get some basic pointers without having to read the full details then I would be happy to try an install on one of my ubuntu machines.

Additional note is that I have installed the windows binary (0.99.1) on a python2.6 install and the same clipping behaviour occurs (no arrows to be seen) the same script run on the my work machine (2.5 and 0.98.xxx) works fine (arrows to be seen in all their glory). Tomorrow I will send through the outputs from the various machines I have to see if I can find when the world changed for these arrows.

Finally, can you reproduce the phenomenon that I see on your install of matplotlib?

Thank you very much for the guidance,

Kurt

···

From: lee.j.joon@…287…
Date: Tue, 19 Jan 2010 08:52:24 -0500
Subject: Re: [Matplotlib-users] Annotate Behaviour - Arrows Missing
To: kurtforrester@…32…
CC: matplotlib-users@lists.sourceforge.net

On Tue, Jan 19, 2010 at 2:48 AM, Kurt Forrester > <kurtforrester@…32…> wrote:

I modified the script for the hax. annotate(…) to include the
annotate_clip=False, however there is no change in the behaviour of the
arrows.

It should be “annotation_clip” not “annotate_clip”, but it may be just a typo.

Anyhow, as far as I know (as I wrote the related code), there is no
other setting. And your script work fine for me when “annotation_clip”
parameter is added. While I’m testing this with the current svn
version of matplolib, I don’t think I see any bug fix related with
this after 0.99.0 release.

Anyhow, It would be great if you can install the newest version of
matplotlib (0.99.1 or even svn) and see if arrows are still missing.

Regards,

-JJ


Sell your old one fast! Time for a new car?

The "annotation_clip" feature is introduced in 0.99.0, and annotations
are not clipped before that version.
Again, your script works fine if I add annotation_clip parameter. So,
I'm not sure what's going on. Can anyone else reproduce this problem?

Just in case, with the following code, do you see label "Test"? It
should be seen near where the xlabel is seen.

fig = figure()
ax=subplot(111)
ax.annotate("Test", (-0.1, 0.5), annotation_clip=False)

Regards,

-JJ

···

On Tue, Jan 19, 2010 at 3:08 PM, Kurt Forrester <kurtforrester@...32...> wrote:

Additional information that I forgot to supply was that on python
2.5/windows/matplotlib 0.98.xxx (my work machine, not accessible at the
moment for the subversion number) this worked fine and there may have been a
regression from this to the current 0.99.0 (in the ubuntu repository).

From: lee.j.joon@…287…
Date: Wed, 20 Jan 2010 12:18:42 -0500
Subject: Re: [Matplotlib-users] Annotate Behaviour - Arrows Missing
To: kurtforrester@…32…
CC: matplotlib-users@…813…ourceforge.net

Additional information that I forgot to supply was that on python
2.5/windows/matplotlib 0.98.xxx (my work machine, not accessible at the
moment for the subversion number) this worked fine and there may have been a
regression from this to the current 0.99.0 (in the ubuntu repository).

The “annotation_clip” feature is introduced in 0.99.0, and annotations
are not clipped before that version.
Again, your script works fine if I add annotation_clip parameter. So,
I’m not sure what’s going on. Can anyone else reproduce this problem?

Just in case, with the following code, do you see label “Test”? It
should be seen near where the xlabel is seen.

fig = figure()
ax=subplot(111)
ax.annotate(“Test”, (-0.1, 0.5), annotation_clip=False)

Regards,

-JJ

I do not see the text “Test” where it should be on my windows machine
running python 2.6 and matplotlib 0.99.1. On the same machine before
clipping was available (python 2.5 and matplotlib 0.98.5.3) I do see
the relevant text (after removing the relevant part from the script).

Just to summarise on my machines (2 Ubuntu Karmic and 2 Windows XP)
running matplotlib 0.99.x the annotation is clipped regardless of the
setting parsed when the annotation if the annotation xy co-ordinates
are outside of the axes visible range any direction.

Replacing the string with a long string like “Test the use of a very
long string to see if it does partial clipping even if it passes the
full length of the x-axes” is still not visible (not any part of it)
until the beginning of the string “T” in Test is withing the positive
range of both the x and y axes.

If I pan the axes, dragging the limits so that the text moves off the
visible axes in the positive direction, the text is still visible when
it passes through the maximum value in the x direction until the xy co-ords move beyond the x-max and it is again clipped.

Attached are two slightly different versions of the same figure that
have been panned to demonstrate the visual differences. Note the
marginal difference in the x-axes lower limit and the text just
disappears. I would have expected the text to still be visible (that
which should be drawn in the visible axes). Just to confirm the setting
of annotation_clip=False in the script that generated the figure.

I am not too sure what the design behaviour is but it is certainly not
doing what I expected. I do appreciate your effort in resolving this.
Please do let me know if there are any further tests I can perform to
demonstrate the issue or test for fixes.

Kind Regards,

Kurt

···

On Tue, Jan 19, 2010 at 3:08 PM, Kurt Forrester > <kurtforrester@…32…> wrote:


Sell your old one fast! Time for a new car?

"annotate" is meant to annotate a data point. It does not have much
meaning to draw the annotating text when the annotated data point is
not visible (i.e. when the data point is outside the axes). And this
is the default behavior of the current matplotlib.

As I cannot reproduce the problem, it is hard to track down what is wrong.
I'm attaching a little debugging script. Please try to run this code
and report the output. For example, I get

annotation_clip = False
_check_xy returning True
Drawing Text

Your output may be different.

Regards,

-JJ

annotate_debug.py (1.81 KB)

···

On Wed, Jan 20, 2010 at 1:13 PM, Kurt Forrester <kurtforrester@...32...> wrote:

I am not too sure what the design behaviour is but it is certainly not doing
what I expected. I do appreciate your effort in resolving this. Please do
let me know if there are any further tests I can perform to demonstrate the
issue or test for fixes.

From: lee.j.joon@…287…
Date: Wed, 20 Jan 2010 13:50:45 -0500
Subject: Re: [Matplotlib-users] Annotate Behaviour - Arrows Missing
To: kurtforrester@…32…
CC: matplotlib-users@lists.sourceforge.net

I am not too sure what the design behaviour is but it is certainly not doing
what I expected. I do appreciate your effort in resolving this. Please do
let me know if there are any further tests I can perform to demonstrate the
issue or test for fixes.

“annotate” is meant to annotate a data point. It does not have much
meaning to draw the annotating text when the annotated data point is
not visible (i.e. when the data point is outside the axes). And this
is the default behavior of the current matplotlib.

As I cannot reproduce the problem, it is hard to track down what is wrong.
I’m attaching a little debugging script. Please try to run this code
and report the output. For example, I get

annotation_clip = False
_check_xy returning True
Drawing Text

Your output may be different.

Regards,

-JJ

thanks for the details on the design.

the output from the script is:

annotation_clip = None
checking is point is inside the axes : [ 30.875 233. ]
contains_point = 0
_check_xy returning False
exit without drawing due to annotation_clip

···

On Wed, Jan 20, 2010 at 1:13 PM, Kurt Forrester > <kurtforrester@…32…> wrote:


Start searching NOW! Search for properties that match your lifestyle!

Weird.
How about this one?

fig = figure()
ax=subplot(111)
txt = ax.annotate("Test", (-0.1, 0.5), annotation_clip=False)
print txt.get_annotation_clip()

If it still print out None, see if the next code make any difference.

fig = figure()
ax=subplot(111)
txt = ax.annotate("Test", (-0.1, 0.5))
txt.set_annotation_clip(False)
print txt.get_annotation_clip()

-JJ

···

On Wed, Jan 20, 2010 at 3:07 PM, Kurt Forrester <kurtforrester@...32...> wrote:

the output from the script is:

annotation_clip = None
checking is point is inside the axes : [ 30.875 233. ]
contains_point = 0
_check_xy returning False
exit without drawing due to annotation_clip

From: lee.j.joon@…287…
Date: Wed, 20 Jan 2010 17:35:21 -0500
Subject: Re: [Matplotlib-users] Annotate Behaviour - Arrows Missing
To: kurtforrester@…32…
CC: matplotlib-users@lists.sourceforge.net

the output from the script is:

annotation_clip = None
checking is point is inside the axes : [ 30.875 233. ]
contains_point = 0
_check_xy returning False
exit without drawing due to annotation_clip

Weird.
How about this one?

fig = figure()
ax=subplot(111)
txt = ax.annotate(“Test”, (-0.1, 0.5), annotation_clip=False)
print txt.get_annotation_clip()

If it still print out None, see if the next code make any difference.

fig = figure()
ax=subplot(111)
txt = ax.annotate(“Test”, (-0.1, 0.5))
txt.set_annotation_clip(False)
print txt.get_annotation_clip()

-JJ

The first one reported None.
The second one reported False.

Kurt

···

On Wed, Jan 20, 2010 at 3:07 PM, Kurt Forrester > <kurtforrester@…32…> wrote:


Sell your old one fast! Time for a new car?

And the text is still not drawn with the second example?

-JJ

···

On Thu, Jan 21, 2010 at 9:37 AM, Kurt Forrester <kurtforrester@...32...> wrote:

The first one reported None.
The second one reported False.

From: lee.j.joon@…287…
Date: Thu, 21 Jan 2010 10:46:00 -0500
Subject: Re: [Matplotlib-users] Annotate Behaviour - Arrows Missing
To: kurtforrester@…32…
CC: matplotlib-users@lists.sourceforge.net

The first one reported None.
The second one reported False.

And the text is still not drawn with the second example?

-JJ

Sorry the text IS drawn in the second example. So the setting of the attribute after it is drawn (before it is shown) seems to do the trick.

Kurt

···

On Thu, Jan 21, 2010 at 9:37 AM, Kurt Forrester > <kurtforrester@…32…> wrote:


Start searching NOW! Search for properties that match your lifestyle!

It seems that somehow the annotation_clip parameter is ignored when it
is given during the object creation. While I'm not 100% sure, this
seems to be fixed in the current svn where it does work.

And I presume your original script will also work if you call
set_annotation_clip explicitly.
Let me know if there is any other problem.

Regards,

-JJ

···

On Thu, Jan 21, 2010 at 12:53 PM, Kurt Forrester <kurtforrester@...32...> wrote:

Sorry the text IS drawn in the second example. So the setting of the
attribute after it is drawn (before it is shown) seems to do the trick.

Kurt

From: lee.j.joon@…287…
Date: Thu, 21 Jan 2010 13:21:41 -0500
Subject: Re: [Matplotlib-users] Annotate Behaviour - Arrows Missing
To: kurtforrester@…32…
CC: matplotlib-users@lists.sourceforge.net

Sorry the text IS drawn in the second example. So the setting of the
attribute after it is drawn (before it is shown) seems to do the trick.

Kurt

It seems that somehow the annotation_clip parameter is ignored when it
is given during the object creation. While I’m not 100% sure, this
seems to be fixed in the current svn where it does work.

And I presume your original script will also work if you call
set_annotation_clip explicitly.
Let me know if there is any other problem.

Regards,

-JJ

JJ,

I can confirm that by calling .set_annotation_clip(False) after the creation of the object makes all the annotations appear as expected. I will amend my code until I get the latest version installed.

Just to add one more query to the thread, do you consider a point on a vertex of the axes to be a candidate for annotation without clipping? That is to say if there is a point (0,0) I wish to annotate, and the origin of the axes contains that point (0,0), would you (by design) want to be able to annotate that point? My initial uncertainty as to why I need to have the clipping turned to False in the first instance is because I thought that if a point may fall on a any of the vertices they still should be considered in the visible field.

This is just a thought.

Thank you for your effort on this.

Kind Regards.,

Kurt

···

On Thu, Jan 21, 2010 at 12:53 PM, Kurt Forrester > <kurtforrester@…32…> wrote:


Sell your old one fast! Time for a new car?

I would agree with you. However, the current behavior inherits from
how "inside test" is done for paths in general (point_in_path_impl in
src/_path.cpp). So there is not much thing I can help. We may check
if the point is "on" the path addiitionally, but I'm not sure if there
is a relevant routine (while there is point_on_path, but I'm not sure
if this is it). I'll try to take a further look later.

Regards,

-JJ

···

On Thu, Jan 21, 2010 at 4:13 PM, Kurt Forrester <kurtforrester@...32...> wrote:

Just to add one more query to the thread, do you consider a point on a
vertex of the axes to be a candidate for annotation without clipping? That
is to say if there is a point (0,0) I wish to annotate, and the origin of
the axes contains that point (0,0), would you (by design) want to be able to
annotate that point? My initial uncertainty as to why I need to have the
clipping turned to False in the first instance is because I thought that if
a point may fall on a any of the vertices they still should be considered
in the visible field.