22
33import numpy as np
44
5+ import matplotlib as mpl
56from matplotlib .patches import _Style , FancyArrowPatch
6- from matplotlib .transforms import IdentityTransform
77from matplotlib .path import Path
8+ from matplotlib .transforms import IdentityTransform
89
910
1011class _FancyAxislineStyle :
@@ -54,10 +55,10 @@ def set_path(self, path):
5455 def draw (self , renderer ):
5556 """
5657 Draw the axis line.
57- 1) transform the path to the display coordinate.
58- 2) extend the path to make a room for arrow
59- 3) update the path of the FancyArrowPatch.
60- 4) draw
58+ 1) Transform the path to the display coordinate.
59+ 2) Extend the path to make a room for arrow.
60+ 3) Update the path of the FancyArrowPatch.
61+ 4) Draw.
6162 """
6263 path_in_disp = self ._line_transform .transform_path (self ._line_path )
6364 mutation_size = self .get_mutation_scale () # line_mutation_scale()
@@ -67,9 +68,15 @@ def draw(self, renderer):
6768 FancyArrowPatch .draw (self , renderer )
6869
6970 class FilledArrow (SimpleArrow ):
70- """The artist class that will be returned for SimpleArrow style."""
71+ """The artist class that will be returned for FilledArrow style."""
7172 _ARROW_STYLE = "-|>"
7273
74+ def __init__ (self , axis_artist , line_path , transform ,
75+ line_mutation_scale , facecolor ):
76+ super ().__init__ (axis_artist , line_path , transform ,
77+ line_mutation_scale )
78+ self .set_facecolor (facecolor )
79+
7380
7481class AxislineStyle (_Style ):
7582 """
@@ -131,7 +138,6 @@ def __init__(self, size=1):
131138 super ().__init__ ()
132139
133140 def new_line (self , axis_artist , transform ):
134-
135141 linepath = Path ([(0 , 0 ), (0 , 1 )])
136142 axisline = self .ArrowAxisClass (axis_artist , linepath , transform ,
137143 line_mutation_scale = self .size )
@@ -140,6 +146,27 @@ def new_line(self, axis_artist, transform):
140146 _style_list ["->" ] = SimpleArrow
141147
142148 class FilledArrow (SimpleArrow ):
149+ def __init__ (self , size = 1 , facecolor = mpl .rcParams ['axes.edgecolor' ]):
150+ """
151+ Parameters
152+ ----------
153+ size : float
154+ Size of the arrow as a fraction of the ticklabel size.
155+ facecolor : color, default: :rc:`axes.edgecolor`
156+ Fill color.
157+ """
158+
159+ self .size = size
160+ self ._facecolor = facecolor
161+ super ().__init__ (size = size )
162+
163+ def new_line (self , axis_artist , transform ):
164+ linepath = Path ([(0 , 0 ), (0 , 1 )])
165+ axisline = self .ArrowAxisClass (axis_artist , linepath , transform ,
166+ line_mutation_scale = self .size ,
167+ facecolor = self ._facecolor )
168+ return axisline
169+
143170 ArrowAxisClass = _FancyAxislineStyle .FilledArrow
144171
145172 _style_list ["-|>" ] = FilledArrow
0 commit comments