Neil,

I have attached code to draw the arrowhead.

-Ben

# -*- coding: utf-8 -*-
"""
Spyder Editor

This is a temporary script file.
"""

import custom_annotations
import matplotlib.pyplot as plt

plt.figure()
ax = plt.subplot(111)
length = 20.0
head_length = 7.0
#Convert the head length from mm into points (1/72")
head_length_pts = head_length * 72.0/25.4
#Calculate the head width
head_aspect_ratio = 2.5
head_width_pts = head_length_pts / head_aspect_ratio
#Define arrow style
style_str = '-)>'
arrowstyle_str = style_str + ', head_width = ' + str(head_width_pts) + \
    ', head_length = ' + str(head_length_pts) + ', length = ' + str(length * 72/25.4)
#Sets arrow orientation
x_1 = [0.25, 0.5]
#Sets arrowhead tip position
x_2 = [0.5, 0.5]
ax.annotate('', xytext = x_1, textcoords = 'axes fraction', \
    xy = x_2, xycoords = 'axes fraction', clip_on = False, \
    arrowprops = dict(arrowstyle = arrowstyle_str, mutation_scale = 1.0, \
    linewidth = 1, facecolor = [0,0,0], connectionstyle = 'arc3', \
    shrinkA = 0, shrinkB = 0))

On May 13, 2015, at 7:44 PM, Neil Girdhar <mistersh...@gmail.com> wrote:

Do you have the code that you used to draw the arrowhead?  I'm up to date now on the development workflow (http://matplotlib.org/devel/gitwash/development_workflow.html), so I'm ready to start working.

Thanks,

Neil

On Wed, May 13, 2015 at 9:10 PM, Benjamin Reedlunn <breed...@gmail.com> wrote:
Yes, I fully agree that we need to unify the many different ways to draw arrows.  

Neil, in case an example would be helpful for you, I have attached a module that includes a custom arrowhead class.  The arrowhead class works with the with the ax.annotate() method.  (I like the annotate method because it allows me to easily mix and match coordinate systems for arrow placement.)  As you can see in the attached pdf, the custom arrowhead doesn't include fancy Bezier curves, but that could be added.

-Ben



On May 13, 2015, at 2:54 PM, Thomas Caswell <tcasw...@gmail.com> wrote:

The other thing that should be done is to unify the (I think 7?!?) unique ways to draw arrows in mpl.

On Wed, May 13, 2015 at 4:52 PM Neil Girdhar <mistersh...@gmail.com> wrote:
Yes, I just noticed that as well.  That's how the tikz pgf code looks (a sequence of line_to and curve_to commands and so on) so it should be easy to port over the various shapes.

On Wed, May 13, 2015 at 4:49 PM, Eric Firing <efir...@hawaii.edu> wrote:
On 2015/05/13 10:12 AM, Neil Girdhar wrote:
If you want to make arrowheads look at all decent, they really need to
be enclosed in Bezier curves.  See the diagram here:

Mpl paths support Bezier curves.
http://matplotlib.org/api/path_api.html?highlight=bezier


http://tex.stackexchange.com/questions/150289/how-do-you-accomplish-stealth-with-the-new-arrows-meta/230965#230965

The first two look like garbage.  The last one is the only one that
looks good imho.

That depends on the application, and the observer.

Sure, but I may as well port them all of the tikz arrowheads over since most of the work would be figuring out how to do it.
 


Eric


Best,

Neil

On Wed, May 13, 2015 at 4:09 PM, Eric Firing <efir...@hawaii.edu
<mailto:efir...@hawaii.edu>> wrote:

    On 2015/05/13 9:36 AM, Neil Girdhar wrote:

        I don't know matplotlib well enough (yet) to know what the
        change would
        consist of.

        I suggest you take a look at the beautiful tikz manual:
        http://pgf.sourceforge.net/pgf_CVS.pdf


    Very helpful, thank you.


        The arrows.meta on page 201–212 are really well-designed and
        beautiful.

        Compare this with matplotlib's custom arrows:
        http://stackoverflow.com/questions/16968007/custom-arrow-style-for-matplotlib-pyplot-annotate

        How do I make tikz's arrowheads available for all backends?


    My guess offhand is that this is a matter of using the mpl API.  I
    don't think we would want to add all of these types and options to
    the mpl core; but a toolkit might be ideal for this.  The mpl API,
    which generates the same results for all backends, is quite complete
    and flexible.  Things like arrowheads are Patch objects, and you can
    specify any path you want.  The main trick is figuring out how to
    handle transforms--what kind of coordinates should the path be
    specifying?  How should things scale as a figure is reshaped and
    resized?

    For many of these types you could also use mpl Line2D objects, for
    which several properties including cap style can be specified.  Not
    all of the TikZ options would be available, but perhaps enough.

    Eric



------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel




------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to