2
2
3
3
import numpy as np
4
4
5
+ import matplotlib as mpl
5
6
from matplotlib .patches import _Style , FancyArrowPatch
6
- from matplotlib .transforms import IdentityTransform
7
7
from matplotlib .path import Path
8
+ from matplotlib .transforms import IdentityTransform
8
9
9
10
10
11
class _FancyAxislineStyle :
@@ -54,10 +55,10 @@ def set_path(self, path):
54
55
def draw (self , renderer ):
55
56
"""
56
57
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.
61
62
"""
62
63
path_in_disp = self ._line_transform .transform_path (self ._line_path )
63
64
mutation_size = self .get_mutation_scale () # line_mutation_scale()
@@ -67,9 +68,15 @@ def draw(self, renderer):
67
68
FancyArrowPatch .draw (self , renderer )
68
69
69
70
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."""
71
72
_ARROW_STYLE = "-|>"
72
73
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
+
73
80
74
81
class AxislineStyle (_Style ):
75
82
"""
@@ -131,7 +138,6 @@ def __init__(self, size=1):
131
138
super ().__init__ ()
132
139
133
140
def new_line (self , axis_artist , transform ):
134
-
135
141
linepath = Path ([(0 , 0 ), (0 , 1 )])
136
142
axisline = self .ArrowAxisClass (axis_artist , linepath , transform ,
137
143
line_mutation_scale = self .size )
@@ -140,6 +146,30 @@ def new_line(self, axis_artist, transform):
140
146
_style_list ["->" ] = SimpleArrow
141
147
142
148
class FilledArrow (SimpleArrow ):
149
+ def __init__ (self , size = 1 , facecolor = None ):
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
+ .. versionadded:: 3.7
158
+ """
159
+
160
+ if facecolor is None :
161
+ facecolor = mpl .rcParams ['axes.edgecolor' ]
162
+ self .size = size
163
+ self ._facecolor = facecolor
164
+ super ().__init__ (size = size )
165
+
166
+ def new_line (self , axis_artist , transform ):
167
+ linepath = Path ([(0 , 0 ), (0 , 1 )])
168
+ axisline = self .ArrowAxisClass (axis_artist , linepath , transform ,
169
+ line_mutation_scale = self .size ,
170
+ facecolor = self ._facecolor )
171
+ return axisline
172
+
143
173
ArrowAxisClass = _FancyAxislineStyle .FilledArrow
144
174
145
175
_style_list ["-|>" ] = FilledArrow
0 commit comments