@@ -285,15 +285,29 @@ def set_linewidth(self, linewidth, store=True):
285
285
if store :
286
286
self .linewidth = linewidth
287
287
288
+ @staticmethod
289
+ def _linejoin_cmd (linejoin ):
290
+ # Support for directly passing integer values is for backcompat.
291
+ linejoin = {'miter' : 0 , 'round' : 1 , 'bevel' : 2 , 0 : 0 , 1 : 1 , 2 : 2 }[
292
+ linejoin ]
293
+ return f"{ linejoin :d} setlinejoin\n "
294
+
288
295
def set_linejoin (self , linejoin , store = True ):
289
296
if linejoin != self .linejoin :
290
- self ._pswriter .write ("%d setlinejoin \n " % linejoin )
297
+ self ._pswriter .write (self . _linejoin_cmd ( linejoin ) )
291
298
if store :
292
299
self .linejoin = linejoin
293
300
301
+ @staticmethod
302
+ def _linecap_cmd (linecap ):
303
+ # Support for directly passing integer values is for backcompat.
304
+ linecap = {'butt' : 0 , 'round' : 1 , 'projecting' : 2 , 0 : 0 , 1 : 1 , 2 : 2 }[
305
+ linecap ]
306
+ return f"{ linecap :d} setlinecap\n "
307
+
294
308
def set_linecap (self , linecap , store = True ):
295
309
if linecap != self .linecap :
296
- self ._pswriter .write ("%d setlinecap \n " % linecap )
310
+ self ._pswriter .write (self . _linecap_cmd ( linecap ) )
297
311
if store :
298
312
self .linecap = linecap
299
313
@@ -477,10 +491,8 @@ def draw_markers(
477
491
stroke = lw > 0 and alpha > 0
478
492
if stroke :
479
493
ps_cmd .append ('%.1f setlinewidth' % lw )
480
- jint = gc .get_joinstyle ()
481
- ps_cmd .append ('%d setlinejoin' % jint )
482
- cint = gc .get_capstyle ()
483
- ps_cmd .append ('%d setlinecap' % cint )
494
+ ps_cmd .append (self ._linejoin_cmd (gc .get_joinstyle ()))
495
+ ps_cmd .append (self ._linecap_cmd (gc .get_capstyle ()))
484
496
485
497
ps_cmd .append (self ._convert_path (marker_path , marker_trans ,
486
498
simplify = False ))
@@ -675,10 +687,6 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
675
687
grestore
676
688
""" )
677
689
678
- def new_gc (self ):
679
- # docstring inherited
680
- return GraphicsContextPS ()
681
-
682
690
def draw_mathtext (self , gc , x , y , s , prop , angle ):
683
691
"""Draw the math text using matplotlib.mathtext."""
684
692
if debugPS :
@@ -783,10 +791,8 @@ def _draw_ps(self, ps, gc, rgbFace, fill=True, stroke=True, command=None):
783
791
784
792
if mightstroke :
785
793
self .set_linewidth (gc .get_linewidth ())
786
- jint = gc .get_joinstyle ()
787
- self .set_linejoin (jint )
788
- cint = gc .get_capstyle ()
789
- self .set_linecap (cint )
794
+ self .set_linejoin (gc .get_joinstyle ())
795
+ self .set_linecap (gc .get_capstyle ())
790
796
self .set_linedash (* gc .get_dashes ())
791
797
self .set_color (* gc .get_rgb ()[:3 ])
792
798
write ('gsave\n ' )
@@ -839,6 +845,7 @@ def _is_transparent(rgb_or_rgba):
839
845
return False
840
846
841
847
848
+ @cbook .deprecated ("3.4" , alternative = "GraphicsContextBase" )
842
849
class GraphicsContextPS (GraphicsContextBase ):
843
850
def get_capstyle (self ):
844
851
return {'butt' : 0 , 'round' : 1 , 'projecting' : 2 }[super ().get_capstyle ()]
0 commit comments