1+ """
2+ Provides classes to style the axis lines.
3+ """
14import math
25
36import numpy as np
47
8+ import matplotlib as mpl
59from matplotlib .patches import _Style , FancyArrowPatch
6- from matplotlib .transforms import IdentityTransform
710from matplotlib .path import Path
11+ from matplotlib .transforms import IdentityTransform
812
913
1014class _FancyAxislineStyle :
@@ -54,10 +58,10 @@ def set_path(self, path):
5458 def draw (self , renderer ):
5559 """
5660 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
61+ 1) Transform the path to the display coordinate.
62+ 2) Extend the path to make a room for arrow.
63+ 3) Update the path of the FancyArrowPatch.
64+ 4) Draw.
6165 """
6266 path_in_disp = self ._line_transform .transform_path (self ._line_path )
6367 mutation_size = self .get_mutation_scale () # line_mutation_scale()
@@ -67,9 +71,15 @@ def draw(self, renderer):
6771 FancyArrowPatch .draw (self , renderer )
6872
6973 class FilledArrow (SimpleArrow ):
70- """The artist class that will be returned for SimpleArrow style."""
74+ """The artist class that will be returned for FilledArrow style."""
7175 _ARROW_STYLE = "-|>"
7276
77+ def __init__ (self , axis_artist , line_path , transform ,
78+ line_mutation_scale , facecolor ):
79+ super ().__init__ (axis_artist , line_path , transform ,
80+ line_mutation_scale )
81+ self .set_facecolor (facecolor )
82+
7383
7484class AxislineStyle (_Style ):
7585 """
@@ -131,7 +141,6 @@ def __init__(self, size=1):
131141 super ().__init__ ()
132142
133143 def new_line (self , axis_artist , transform ):
134-
135144 linepath = Path ([(0 , 0 ), (0 , 1 )])
136145 axisline = self .ArrowAxisClass (axis_artist , linepath , transform ,
137146 line_mutation_scale = self .size )
@@ -140,6 +149,35 @@ def new_line(self, axis_artist, transform):
140149 _style_list ["->" ] = SimpleArrow
141150
142151 class FilledArrow (SimpleArrow ):
152+ """
153+ An arrow with a filled head.
154+ """
155+
143156 ArrowAxisClass = _FancyAxislineStyle .FilledArrow
144157
158+ def __init__ (self , size = 1 , facecolor = None ):
159+ """
160+ Parameters
161+ ----------
162+ size : float
163+ Size of the arrow as a fraction of the ticklabel size.
164+ facecolor : color, default: :rc:`axes.edgecolor`
165+ Fill color.
166+
167+ .. versionadded:: 3.7
168+ """
169+
170+ if facecolor is None :
171+ facecolor = mpl .rcParams ['axes.edgecolor' ]
172+ self .size = size
173+ self ._facecolor = facecolor
174+ super ().__init__ (size = size )
175+
176+ def new_line (self , axis_artist , transform ):
177+ linepath = Path ([(0 , 0 ), (0 , 1 )])
178+ axisline = self .ArrowAxisClass (axis_artist , linepath , transform ,
179+ line_mutation_scale = self .size ,
180+ facecolor = self ._facecolor )
181+ return axisline
182+
145183 _style_list ["-|>" ] = FilledArrow
0 commit comments