from matplotlib.pyplot import figure, show
from matplotlib.patches import FancyArrowPatch

import matplotlib.patheffects as pe

fig = figure()
ax = fig.add_subplot(111,autoscale_on=False,)
p = FancyArrowPatch((0,0), (1,1),
arrowstyle='-|>,head_width=8,head_length=16',lw=3,fc='k',ec='k',linestyle='dashed')
ax.add_patch(p)

class CheckNthSubPath(object):
    def __init__(self, patch, n):
        """
        creates an callable object that returns True if the provided
        path is the n-th path from the patch.
        """
        self._patch = patch
        self._n = n

    def get_paths(self, renderer):
        self._patch.set_dpi_cor(renderer.points_to_pixels(1.))
        paths, fillables = self._patch.get_path_in_displaycoord()
        return paths

    def __call__(self, renderer, gc, tpath, affine, rgbFace):

        path = self.get_paths(renderer)[self._n]
        vert1, code1 = path.vertices, path.codes
        import numpy as np

        if np.all(vert1 == tpath.vertices) and np.all(code1 == tpath.codes):
            return True
        else:
            return False


class ConditionalStroke(pe._Base):

    def __init__(self, condition_func, pe_list):
        """
        path effect that is only applied when the condition_func
        returns True.
        """
        super(ConditionalStroke, self).__init__()
        self._pe_list = pe_list
        self._condition_func = condition_func

    def draw_path(self, renderer, gc, tpath, affine, rgbFace):

        if self._condition_func(renderer, gc, tpath, affine, rgbFace):
            for pe1 in self._pe_list:
                pe1.draw_path(renderer, gc, tpath, affine, rgbFace)


pe1 = ConditionalStroke(CheckNthSubPath(p, 0),
                        [pe.Stroke()])
pe2 = ConditionalStroke(CheckNthSubPath(p, 1),
                        [pe.Stroke(linestyle="solid")])

p.set_path_effects([pe1, pe2])

show()

