FancyArrowPatch behaves quite differently from normal patches.
Most importantly, the path must be reevaluated during the drawing time, so
a normal PatchCollection, which evaluate the paths during the instance
creation, won't work. i.e., you need a new Collection class.

Below is a very incomplete implementation of FancyArrowPatchCollection,
just for a demonstration purpose. And I recommend you to open a wishlist
ticket at the issue tracker (https://github.com/matplotlib/matplotlib/issues
).

Regards,

-JJ


class FancyArrowPatchCollection(PatchCollection):
    def set_paths(self, patches):
        self._patches = patches

    def get_paths(self):
        paths = []
        for p in self._patches:
            p.set_transform(self.get_transform())
            _path, fillable = p.get_path_in_displaycoord()
            paths.extend(_path)
        return paths

    def _prepare_points(self):
        import matplotlib.transforms as mtransforms
        transform, transOffset, offsets, paths =
PatchCollection._prepare_points(self)
        return mtransforms.IdentityTransform(), transOffset, offsets, paths




On Thu, Jan 31, 2013 at 6:33 AM, Skipper Seabold <jsseab...@gmail.com>wrote:

> Hi,
>
> Trying to figure out why these two do not create the same plot. Bug or
> user error?
>
> import matplotlib.pyplot as plt
> from matplotlib.patches import FancyArrowPatch
> from matplotlib.collections import PatchCollection
>
> def correct_patch(pos):
>     fig, ax = plt.subplots()
>     for src, dst in pos:
>         arrow = FancyArrowPatch(posA=src, posB=dst,
>                                 color='k', arrowstyle='-|>',
>                                 mutation_scale=30, connectionstyle="arc3")
>         ax.add_patch(arrow)
>     return fig
>
> def patch_collection_problem(pos):
>     fig, ax = plt.subplots()
>     pos = [[(.5, .5), (.25, .25)],
>            [(.1, .5), (.2, .75)]]
>     arrows = []
>     for src, dst in pos:
>         arrows.append(FancyArrowPatch(posA=src, posB=dst,
>                                 color='k', arrowstyle='-|>',
>                                 mutation_scale=30, connectionstyle="arc3"))
>     collection = PatchCollection(arrows, match_original=True)
>
>     ax.add_collection(collection, autolim=False)
>     return fig
>
> pos = [[(.5, .5), (.25, .25)],
>           [(.1, .5), (.2, .75)]]
>
> correct_patch(pos)
> patch_collection_problem(pos)
>
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_d2d_jan
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_jan
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to