Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cd54509

Browse files
committed
Deprecate unused 'linestyle' property of GraphicsContextBase.
Also simplify linestyle handling by Line2D.
1 parent 01c314d commit cd54509

File tree

7 files changed

+21
-38
lines changed

7 files changed

+21
-38
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Deprecation of `GraphicsContextBase`\'s ``linestyle`` property.
2+
```````````````````````````````````````````````````````````````
3+
4+
The ``GraphicsContextBase.get_linestyle`` and
5+
``GraphicsContextBase.set_linestyle`` methods, which effectively had no effect,
6+
have been deprecated.

lib/matplotlib/backend_bases.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
import matplotlib.colors as colors
5252
import matplotlib.transforms as transforms
5353
import matplotlib.widgets as widgets
54-
#import matplotlib.path as path
5554
from matplotlib import rcParams
5655
from matplotlib import is_interactive
5756
from matplotlib import get_backend
@@ -300,8 +299,8 @@ def draw_path_collection(self, gc, master_transform, paths, all_transforms,
300299
path_ids.append((path, transforms.Affine2D(transform)))
301300

302301
for xo, yo, path_id, gc0, rgbFace in self._iter_collection(
303-
gc, master_transform, all_transforms, path_ids, offsets,
304-
offsetTrans, facecolors, edgecolors, linewidths, linestyles,
302+
gc, master_transform, all_transforms, path_ids, offsets,
303+
offsetTrans, facecolors, edgecolors, linewidths, linestyles,
305304
antialiaseds, urls, offset_position):
306305
path, transform = path_id
307306
transform = transforms.Affine2D(
@@ -907,6 +906,7 @@ def get_joinstyle(self):
907906
"""
908907
return self._joinstyle
909908

909+
@cbook.deprecated("2.1")
910910
def get_linestyle(self):
911911
"""
912912
Return the linestyle: one of ('solid', 'dashed', 'dashdot',
@@ -1057,6 +1057,7 @@ def set_linewidth(self, w):
10571057
"""
10581058
self._linewidth = float(w)
10591059

1060+
@cbook.deprecated("2.1")
10601061
def set_linestyle(self, style):
10611062
"""
10621063
Set the linestyle to be one of ('solid', 'dashed', 'dashdot',

lib/matplotlib/backends/backend_pdf.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2352,8 +2352,6 @@ def clip_cmd(self, cliprect, clippath):
23522352
(('_hatch', '_hatch_color'), hatch_cmd),
23532353
)
23542354

2355-
# TODO: _linestyle
2356-
23572355
def delta(self, other):
23582356
"""
23592357
Copy properties of other into self and return PDF commands

lib/matplotlib/backends/backend_wx.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import numpy as np
2929

3030
import matplotlib
31+
from matplotlib import cbook
3132
from matplotlib.backend_bases import (RendererBase, GraphicsContextBase,
3233
FigureCanvasBase, FigureManagerBase, NavigationToolbar2,
3334
cursors, TimerBase)
@@ -408,8 +409,6 @@ class GraphicsContextWx(GraphicsContextBase):
408409
'miter': wx.JOIN_MITER,
409410
'round': wx.JOIN_ROUND}
410411

411-
_dashd_wx = wxc.dashd_wx
412-
413412
_cache = weakref.WeakKeyDictionary()
414413

415414
def __init__(self, bitmap, renderer):
@@ -509,6 +508,7 @@ def set_joinstyle(self, js):
509508
self.gfx_ctx.SetPen(self._pen)
510509
self.unselect()
511510

511+
@cbook.deprecated("2.1")
512512
def set_linestyle(self, ls):
513513
"""
514514
Set the line style to be one of
@@ -517,7 +517,7 @@ def set_linestyle(self, ls):
517517
self.select()
518518
GraphicsContextBase.set_linestyle(self, ls)
519519
try:
520-
self._style = GraphicsContextWx._dashd_wx[ls]
520+
self._style = wxc.dashd_wx[ls]
521521
except KeyError:
522522
self._style = wx.LONG_DASH # Style not used elsewhere...
523523

lib/matplotlib/lines.py

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -771,11 +771,9 @@ def draw(self, renderer):
771771
renderer = PathEffectRenderer(self.get_path_effects(), renderer)
772772

773773
renderer.open_group('line2d', self.get_gid())
774-
funcname = self._lineStyles.get(self._linestyle, '_draw_nothing')
775-
if funcname != '_draw_nothing':
774+
if self._lineStyles[self._linestyle] != '_draw_nothing':
776775
tpath, affine = transf_path.get_transformed_path_and_affine()
777776
if len(tpath.vertices):
778-
line_func = getattr(self, funcname)
779777
gc = renderer.new_gc()
780778
self._set_gc_clip(gc)
781779

@@ -798,7 +796,8 @@ def draw(self, renderer):
798796
if self.get_sketch_params() is not None:
799797
gc.set_sketch_params(*self.get_sketch_params())
800798

801-
line_func(renderer, gc, tpath, affine.frozen())
799+
gc.set_dashes(self._dashOffset, self._dashSeq)
800+
renderer.draw_path(gc, tpath, affine.frozen())
802801
gc.restore()
803802

804803
if self._marker and self._markersize > 0:
@@ -1244,26 +1243,6 @@ def set_dashes(self, seq):
12441243
else:
12451244
self.set_linestyle((0, seq))
12461245

1247-
def _draw_solid(self, renderer, gc, path, trans):
1248-
gc.set_linestyle('solid')
1249-
gc.set_dashes(self._dashOffset, self._dashSeq)
1250-
renderer.draw_path(gc, path, trans)
1251-
1252-
def _draw_dashed(self, renderer, gc, path, trans):
1253-
gc.set_linestyle('dashed')
1254-
gc.set_dashes(self._dashOffset, self._dashSeq)
1255-
renderer.draw_path(gc, path, trans)
1256-
1257-
def _draw_dash_dot(self, renderer, gc, path, trans):
1258-
gc.set_linestyle('dashdot')
1259-
gc.set_dashes(self._dashOffset, self._dashSeq)
1260-
renderer.draw_path(gc, path, trans)
1261-
1262-
def _draw_dotted(self, renderer, gc, path, trans):
1263-
gc.set_linestyle('dotted')
1264-
gc.set_dashes(self._dashOffset, self._dashSeq)
1265-
renderer.draw_path(gc, path, trans)
1266-
12671246
def update_from(self, other):
12681247
"""copy properties from other to self"""
12691248
Artist.update_from(self, other)

lib/matplotlib/patheffects.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,6 @@ def draw_path(self, renderer, gc, tpath, affine, rgbFace):
355355

356356
gc0.set_foreground(shadow_rgbFace)
357357
gc0.set_alpha(self._alpha)
358-
gc0.set_linestyle("solid")
359358

360359
gc0 = self._update_gc(gc0, self._gc)
361360
renderer.draw_path(gc0, tpath, affine0, fill_color)

lib/mpl_toolkits/axisartist/axis_artist.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,12 @@ def draw(self, renderer):
156156
join = self._solidjoinstyle
157157
gc.set_joinstyle(join)
158158
gc.set_capstyle(cap)
159+
gc.set_dashes(self._dashOffset, self._dashSeq)
159160

160-
funcname = self._lineStyles.get(self._linestyle, '_draw_nothing')
161-
if funcname != '_draw_nothing':
162-
tpath, affine = self._transformed_path.get_transformed_path_and_affine()
163-
lineFunc = getattr(self, funcname)
164-
lineFunc(renderer, gc, tpath, affine.frozen())
161+
if self._lineStyles[self._linestyle] != '_draw_nothing':
162+
tpath, affine = (
163+
self._transformed_path.get_transformed_path_and_affine())
164+
renderer.draw_path(gc, tpath, affine.frozen())
165165

166166
gc.restore()
167167
renderer.close_group('line2d')

0 commit comments

Comments
 (0)