How to use 'arrow'?

Hi,

How is the syntax for the matplotlib command ‘arrow’? There is not very much to take from the help (see below). An example would be nice.

Thanks
Alex

In [46]: arrow?
Type: function

Base Class: <type ‘function’>
String Form: <function arrow at 0xb77f8a3c>
Namespace: Interactive
File: /usr/lib/python2.4/site-packages/matplotlib/pylab.py
Definition: arrow(*args, **kwargs)

Docstring:
Draws arrow on specified axis from (x,y) to (x+dx,y+dy).
Optional kwargs control the arrow properties:
alpha: float
animated: [True | False]
antialiased or aa: [True | False]

        axes: an axes instance
        clip_box: a matplotlib.transform.Bbox instance
        clip_on: [True | False]
        clip_path: an agg.path_storage instance
        edgecolor or ec: any matplotlib color

        facecolor or fc: any matplotlib color
        figure: a matplotlib.figure.Figure instance
        fill: [True | False]
        hatch: unknown
        label: any string
        linewidth or lw: float

        lod: [True | False]
        picker: [None|float|boolean|callable]
        transform: a matplotlib.transform transformation instance
        visible: [True | False]
        zorder: any number

Addition kwargs: hold = [True|False] overrides default hold state

I usually use the following to make single arrows:

plot([0,1], ‘k.’)

arr1 = pylab.Arrow(0.5, 0.5, 0.1, 0.0, width=0.02)

fig = pylab.gca()

fig.add_patch(arr1)

If in “ipython -pylab” you need to savefig or send another command (e.g. xlabel) or reload/refresh the plot (I can’t remember the command) for the new patch to display. I use this rather than arrow() because I can control the arrow width and other properties. There is also the quiver command which lets you draw many arrows:

quiver([[0, 1, 2]], [[0, 1, 2]], [[0.0, 0.0, 0.0]], [[0.1, 0.1, 0.1]], 0.2)

Cheers,

Jessica

···

On Jul 20, 2007, at 6:32 AM, Alexander Dietz wrote:

Hi,

How is the syntax for the matplotlib command ‘arrow’? There is not very much to take from the help (see below). An example would be nice.

Thanks
Alex

In [46]: arrow?
Type: function
Base Class: <type ‘function’>
String Form: <function arrow at 0xb77f8a3c>
Namespace: Interactive
File: /usr/lib/python2.4/site-packages/matplotlib/pylab.py
Definition: arrow(*args, **kwargs)
Docstring:
Draws arrow on specified axis from (x,y) to (x+dx,y+dy).
Optional kwargs control the arrow properties:
alpha: float
animated: [True | False]
antialiased or aa: [True | False]
axes: an axes instance
clip_box: a matplotlib.transform.Bbox instance
clip_on: [True | False]
clip_path: an agg.path_storage instance
edgecolor or ec: any matplotlib color
facecolor or fc: any matplotlib color
figure: a matplotlib.figure.Figure instance
fill: [True | False]
hatch: unknown
label: any string
linewidth or lw: float
lod: [True | False]
picker: [None|float|boolean|callable]
transform: a matplotlib.transform transformation instance
visible: [True | False]
zorder: any number

Addition kwargs: hold = [True|False] overrides default hold state

This SF.net email is sponsored by: Microsoft

Defy all challenges. Microsoft(R) Visual Studio 2005.

http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/_______________________________________________

Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

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

The automatic docstring generation for this command is badly fouled up, and I can't straighten it out right now. In the meantime, look at the docstring for FancyArrow.__init__ in patches.py. There is also a horrendously complicated example in examples/arrow_demo.py.

Depending on what you want to do, you might find the annotate command to be what you want. I think its docstring is in better shape, as its example: examples/annotate_demo.py.

Eric

Jessica Lu wrote:

···

I usually use the following to make single arrows:

plot([0,1], 'k.')
arr1 = pylab.Arrow(0.5, 0.5, 0.1, 0.0, width=0.02)
fig = pylab.gca()
fig.add_patch(arr1)

If in "ipython -pylab" you need to savefig or send another command (e.g. xlabel) or reload/refresh the plot (I can't remember the command) for the new patch to display. I use this rather than arrow() because I can control the arrow width and other properties. There is also the quiver command which lets you draw many arrows:

quiver([[0, 1, 2]], [[0, 1, 2]], [[0.0, 0.0, 0.0]], [[0.1, 0.1, 0.1]], 0.2)

Cheers,
Jessica

On Jul 20, 2007, at 6:32 AM, Alexander Dietz wrote:

Hi,

How is the syntax for the matplotlib command 'arrow'? There is not very much to take from the help (see below). An example would be nice.

Thanks
  Alex
In [46]: arrow?
Type: function
Base Class: <type 'function'>
String Form: <function arrow at 0xb77f8a3c>
Namespace: Interactive
File: /usr/lib/python2.4/site-packages/matplotlib/pylab.py
Definition: arrow(*args, **kwargs)
Docstring:
    Draws arrow on specified axis from (x,y) to (x+dx,y+dy).
    Optional kwargs control the arrow properties:
            alpha: float
            animated: [True | False]
            antialiased or aa: [True | False]
            axes: an axes instance
            clip_box: a matplotlib.transform.Bbox instance
            clip_on: [True | False]
            clip_path: an agg.path_storage instance
            edgecolor or ec: any matplotlib color
            facecolor or fc: any matplotlib color
            figure: a matplotlib.figure.Figure instance
            fill: [True | False]
            hatch: unknown
            label: any string
            linewidth or lw: float
            lod: [True | False]
            picker: [None|float|boolean|callable]
            transform: a matplotlib.transform transformation instance
            visible: [True | False]
            zorder: any number

    Addition kwargs: hold = [True|False] overrides default hold state

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net <mailto:Matplotlib-users@lists.sourceforge.net>
matplotlib-users List Signup and Options

------------------------------------------------------------------------

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

------------------------------------------------------------------------

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