@@ -27,7 +27,7 @@ class Front(mpatheffects.AbstractPathEffect):
2727 [mpath .Path .MOVETO , mpath .Path .LINETO ,
2828 mpath .Path .LINETO , mpath .Path .LINETO , mpath .Path .CLOSEPOLY ])
2929
30- def __init__ (self , color , size = 10 , spacing = 1 , flip = False ):
30+ def __init__ (self , color , size = 10 , spacing = 1 , flip = False , filled = True ):
3131 """Initialize the front path effect.
3232
3333 Parameters
@@ -41,13 +41,16 @@ def __init__(self, color, size=10, spacing=1, flip=False):
4141 flip : bool
4242 Whether the symbol should be flipped to the other side of the path. Defaults
4343 to `False`.
44+ filled : bool
45+ Whether the symbol should be filled with the color. Defaults to `True`.
4446
4547 """
4648 super ().__init__ ()
4749 self .size = size
4850 self .spacing = spacing
4951 self .color = mcolors .to_rgba (color )
5052 self .flip = flip
53+ self .filled = filled
5154 self ._symbol_width = None
5255
5356 @cached_property
@@ -130,7 +133,8 @@ def draw_path(self, renderer, gc, path, affine, rgbFace=None): # noqa: N803
130133 for ind , marker_offset in zip (segment_indices , marker_offsets ):
131134 sym_trans = self ._get_symbol_transform (renderer , marker_offset , line_shift ,
132135 angles [ind ], starts [ind ])
133- renderer .draw_path (gc0 , self ._symbol , sym_trans , self .color )
136+ renderer .draw_path (gc0 , self ._symbol , sym_trans ,
137+ self .color if self .filled else None )
134138
135139 gc0 .restore ()
136140
@@ -510,62 +514,8 @@ class Dryline(Front):
510514
511515 _symbol = mpath .Path .wedge (0 , 180 ).transformed (mtransforms .Affine2D ().translate (1 , 0 ))
512516
513- def __init__ (self , color = 'brown' , spacing = 0 , ** kwargs ):
514- super ().__init__ (color , spacing = spacing , ** kwargs )
515-
516- def _step_size (self , renderer , gc ):
517- """Return the length of the step between markers in pixels."""
518- return (
519- self .symbol_width + self .spacing
520- ) * self ._size_pixels (renderer ) + gc .get_linewidth () * 2
521-
522- def _get_marker_locations (self , segment_offsets , renderer , gc ):
523- # Calculate increment of path length occupied by each marker drawn
524- inc = self ._step_size (renderer , gc )
525-
526- # Find out how many markers that will accommodate, as well as remainder space
527- num , leftover = divmod (segment_offsets [- 1 ], inc )
528-
529- # Find the offset for each marker along the path length. We center along
530- # the path by adding half of the remainder. The offset is also centered within
531- # the marker by adding half of the marker increment
532- marker_offsets = np .arange (num ) * inc + (leftover + inc ) / 2.
533-
534- # Find the location of these offsets within the total offset within each
535- # path segment; subtracting 1 gives us the left point of the path rather
536- # than the last. We then need to adjust for any offsets that are <= the first
537- # point of the path (just set them to index 0).
538- inds = np .searchsorted (segment_offsets , marker_offsets ) - 1
539- inds [inds < 0 ] = 0
540-
541- # Return the indices to the proper segment and the offset within that segment
542- return inds , marker_offsets - segment_offsets [inds ]
543-
544- def draw_path (self , renderer , gc , path , affine , rgbFace = None ): # noqa: N803
545- """Draw the given path."""
546- # Set up a new graphics context for rendering the front effect; override the color
547- gc0 = self ._override_gc (renderer , gc , foreground = self .color )
548-
549- # Get the information we need for drawing along the path
550- starts , offsets , angles = self ._process_path (path , affine )
551-
552- # Figure out what segments the markers should be drawn upon and how
553- # far within that segment the markers will appear.
554- segment_indices , marker_offsets = self ._get_marker_locations (offsets , renderer , gc )
555-
556- # Draw the original path
557- renderer .draw_path (gc0 , path , affine , rgbFace ) # noqa: N803
558-
559- # Need to account for the line width in order to properly draw symbols at line edge
560- line_shift = renderer .points_to_pixels (gc .get_linewidth ()) / 2
561-
562- # Loop over all the markers to draw
563- for ind , marker_offset in zip (segment_indices , marker_offsets ):
564- sym_trans = self ._get_symbol_transform (renderer , marker_offset , line_shift ,
565- angles [ind ], starts [ind ])
566- renderer .draw_path (gc0 , self ._symbol , sym_trans , None )
567-
568- gc0 .restore ()
517+ def __init__ (self , color = 'brown' , spacing = 0.144 , filled = False , ** kwargs ):
518+ super ().__init__ (color , spacing = spacing , filled = filled , ** kwargs )
569519
570520
571521@exporter .export
@@ -894,8 +844,8 @@ def draw_path(self, renderer, gc, path, affine, rgbFace=None): # noqa: N803
894844class StationaryFront (Front ):
895845 """Draw a stationary front as alternating cold and warm front segments."""
896846
897- _symbol = WarmFront ._symbol
898- _symbol2 = ColdFront ._symbol . transformed ( mtransforms . Affine2D (). scale ( 1 , - 1 ))
847+ _symbol = WarmFront ._symbol . transformed ( mtransforms . Affine2D (). scale ( 1 , - 1 ))
848+ _symbol2 = ColdFront ._symbol
899849
900850 def __init__ (self , colors = ('red' , 'blue' ), ** kwargs ):
901851 """Initialize a stationary front path effect.
@@ -952,7 +902,7 @@ def draw_path(self, renderer, gc, path, affine, rgbFace=None): # noqa: N803
952902 start_path_inds = np .concatenate ([[0 ], end_path_inds [:- 1 ]])
953903
954904 # Need to account for the line width in order to properly draw symbols at line edge
955- line_shift = renderer .points_to_pixels (gc .get_linewidth ()) / 2
905+ line_shift = - renderer .points_to_pixels (gc .get_linewidth ()) / 2
956906
957907 # Loop over all the markers to draw
958908 for ind , start_path , end_path , marker_offset in zip (segment_indices , start_path_inds ,
0 commit comments