annotation with fancy arrow

John and others,

I submitted a patch of the fancy arrow I mentioned a while ago.

http://sourceforge.net/tracker2/?func=detail&aid=2209021&group_id=80706&atid=560722

I kept my FancyArrowPatch as a separate class instead of merging it
with existing classes.
Instead, I modified the Annotation class so that it optionally uses
FancyArrowPatch.

A simple example usage is

    ax.annotate('test', xy=(0, 1), xycoords='data',
                xytext=(-50, 30), textcoords='offset points',
                arrowprops=dict(arrowstyle="->")
                )

FancyArrowPatch is used if arrowprops has a "arrowstyle" key, similar
to what I have done with FancyBox.

I added a new file "bezier_util.py" which includes some utility
functions. Maybe we may put some (or all) into path.py?
I also added a new example file "annotation_demo2.py".

The outputs of the example file are attached.

I'll appreciate if you review my patch.
Any comments or feedback is welcomed.

Regards,

-JJ

annotation_connection.png

annotation_arrowstyle.png

Hi Jae Joon -- sorry for not responding. I had completely missed
this. Reminding us on the mailing list is definitely a good idea
because I tend to fall behind quite often.

The patch and new example look great. My only requests for changes
(or for next time) are stylistic:

  - when making a significant contribution like this, please add a
change to the CHANGELOG, since that is what many people use to see
what's new and what we use to make the release notes. I've done this
already for this one.

  - try and document every method using the rest documentation
conventions. See
http://matplotlib.sourceforge.net/devel/documenting_mpl.html. Since
we have been working hard on the website and API docs, the one thing
I'd like to ask of you is to make sure all the docstrings are updated
including a bit of module level documentation in bezier -- then I will
add bezier to the API docs

  - for triple quoted docstrings, I would like to stick to the format::

    def myfunc(args):
        """"
        this is my docstring
        """"

   rather than

    def myfunc(args):
        """"this is my docstring
        """"

  - I renamed bezier_util to bezier (PEP8 style guide advises to avoid
underscores and make module names as short as is reasonable), and we
should import it with the full name "from matplotlib.bezier import
..." rather than "from bezier import ..."

  - is using a string for connectionstyle the best choice? Ie, instead of::

      connectionstyle="angle,angleA=0,angleB=90,rad=10"

    would we rather have something like::

      connectionstyle=connectionstyle.angle(angleA=0,angleB=90,rad=10)

    The latter looks more pythonthic and extensible, because if we document the
    connectionstyle API users can provide their own.

These are of course mostly minor stylistic nits, but I want the code
to be as uniform as possible.

I've committed this to svn r6353, and updated the website, so you can
see your examples in the gallery and examples pages:

  http://matplotlib.sourceforge.net/gallery.html
  http://matplotlib.sourceforge.net/gallery.html

Very nice contribution!
JDH

···

On Thu, Oct 30, 2008 at 12:32 AM, Jae-Joon Lee <lee.j.joon@...149...> wrote:

John and others,

I submitted a patch of the fancy arrow I mentioned a while ago.

http://sourceforge.net/tracker2/?func=detail&aid=2209021&group_id=80706&atid=560722

Line 2900 in patches.py is not compatible with python-2.6. “as” is protected and cannot be used as a variable name.

···

On Thursday 30 October 2008 09:49:24 am John Hunter wrote:

On Thu, Oct 30, 2008 at 12:32 AM, Jae-Joon Lee <lee.j.joon@…149…> wrote:

John and others,

I submitted a patch of the fancy arrow I mentioned a while ago.

http://sourceforge.net/tracker2/?func=detail&aid=2209021&group_id=80706&a

tid=560722

Hi Jae Joon – sorry for not responding. I had completely missed

this. Reminding us on the mailing list is definitely a good idea

because I tend to fall behind quite often.

The patch and new example look great. My only requests for changes

(or for next time) are stylistic:

  • when making a significant contribution like this, please add a

change to the CHANGELOG, since that is what many people use to see

what’s new and what we use to make the release notes. I’ve done this

already for this one.

  • try and document every method using the rest documentation

conventions. See

http://matplotlib.sourceforge.net/devel/documenting_mpl.html. Since

we have been working hard on the website and API docs, the one thing

I’d like to ask of you is to make sure all the docstrings are updated

including a bit of module level documentation in bezier – then I will

add bezier to the API docs

  • for triple quoted docstrings, I would like to stick to the format::

def myfunc(args):

“”""

this is my docstring

“”""

rather than

def myfunc(args):

“”""this is my docstring

“”""

  • I renamed bezier_util to bezier (PEP8 style guide advises to avoid

underscores and make module names as short as is reasonable), and we

should import it with the full name "from matplotlib.bezier import

…" rather than “from bezier import …”

  • is using a string for connectionstyle the best choice? Ie, instead

of::

connectionstyle=“angle,angleA=0,angleB=90,rad=10”

would we rather have something like::

connectionstyle=connectionstyle.angle(angleA=0,angleB=90,rad=10)

The latter looks more pythonthic and extensible, because if we document

the connectionstyle API users can provide their own.

These are of course mostly minor stylistic nits, but I want the code

to be as uniform as possible.

I’ve committed this to svn r6353, and updated the website, so you can

see your examples in the gallery and examples pages:

http://matplotlib.sourceforge.net/gallery.html

http://matplotlib.sourceforge.net/gallery.html

Very nice contribution!

JDH


This SF.Net email is sponsored by the Moblin Your Move Developer’s

challenge Build the coolest Linux based applications with Moblin SDK & win

great prizes Grand prize is a trip for two to an Open Source event anywhere

in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/


Matplotlib-devel mailing list

Matplotlib-devel@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Darren S. Dale, Ph.D.

Staff Scientist

Cornell High Energy Synchrotron Source

Cornell University

275 Wilson Lab

Rt. 366 & Pine Tree Road

Ithaca, NY 14853

darren.dale@…143…

office: (607) 255-3819

fax: (607) 255-9001

http://www.chess.cornell.edu

good catch - -fixed in r6355

JDH

···

On Thu, Oct 30, 2008 at 9:28 AM, Darren Dale <darren.dale@...143...> wrote:

Line 2900 in patches.py is not compatible with python-2.6. "as" is protected
and cannot be used as a variable name.

John,
Thanks for the advice. I'll try to put some mre effort on the documentation.

- is using a string for connectionstyle the best choice? Ie, instead of::

     connectionstyle="angle,angleA=0,angleB=90,rad=10"

   would we rather have something like::

     connectionstyle=connectionstyle.angle(angleA=0,angleB=90,rad=10)

   The latter looks more pythonthic and extensible, because if we document the
   connectionstyle API users can provide their own.

Yes, I agree.
As you know, I used strings for the "boxstyle" and the "arrowstyle"
also, in a similar way of linestyle.
But the string for connectionstyle seems to get too complicated.
It is currently possible to do something like below,

  connetionstyle="custom",
  connector=patches.AngleConnector(angleA=0, angleB=90, rad=10)

But I guess this can be simplified.
And, I may gather those Connector classes under a single class (or a
module). And same for arrowstyle classes and boxstyle classes.

Regards,

-JJ

Yes, I think this is the way to go -- uses classes for all of these
rather than strings.

JDH

···

On Fri, Oct 31, 2008 at 5:12 AM, Jae-Joon Lee <lee.j.joon@...149...> wrote:

But I guess this can be simplified.
And, I may gather those Connector classes under a single class (or a
module). And same for arrowstyle classes and boxstyle classes.