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

Skip to content

Commit 5d06a35

Browse files
committed
Merge pull request #4327 from tacaswell/fix_lw_float_cast
Fix lw float cast
2 parents a6af675 + e6b00a1 commit 5d06a35

File tree

6 files changed

+15
-11
lines changed

6 files changed

+15
-11
lines changed

lib/matplotlib/backend_bases.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,7 @@ def set_linewidth(self, w):
10411041
"""
10421042
Set the linewidth in points
10431043
"""
1044-
self._linewidth = w
1044+
self._linewidth = float(w)
10451045

10461046
def set_linestyle(self, style):
10471047
"""

lib/matplotlib/backends/backend_cairo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ def set_joinstyle(self, js):
407407

408408

409409
def set_linewidth(self, w):
410-
self._linewidth = w
410+
self._linewidth = float(w)
411411
self.ctx.set_line_width (self.renderer.points_to_pixels(w))
412412

413413

lib/matplotlib/backends/backend_ps.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ def set_color(self, r, g, b, store=1):
259259
if store: self.color = (r,g,b)
260260

261261
def set_linewidth(self, linewidth, store=1):
262+
linewidth = float(linewidth)
262263
if linewidth != self.linewidth:
263264
self._pswriter.write("%1.3f setlinewidth\n"%linewidth)
264265
if store: self.linewidth = linewidth
@@ -451,10 +452,10 @@ def option_scale_image(self):
451452
ps backend support arbitrary scaling of image.
452453
"""
453454
return True
454-
455+
455456
def option_image_nocomposite(self):
456457
"""
457-
return whether to generate a composite image from multiple images on
458+
return whether to generate a composite image from multiple images on
458459
a set of axes
459460
"""
460461
return not rcParams['image.composite_image']

lib/matplotlib/backends/backend_wx.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -558,12 +558,15 @@ def set_linewidth(self, w):
558558
"""
559559
Set the line width.
560560
"""
561+
w = float(w)
561562
DEBUG_MSG("set_linewidth()", 1, self)
562563
self.select()
563-
if w>0 and w<1: w = 1
564+
if w > 0 and w < 1:
565+
w = 1
564566
GraphicsContextBase.set_linewidth(self, w)
565567
lw = int(self.renderer.points_to_pixels(self._linewidth))
566-
if lw==0: lw = 1
568+
if lw == 0:
569+
lw = 1
567570
self._pen.SetWidth(lw)
568571
self.gfx_ctx.SetPen(self._pen)
569572
self.unselect()
@@ -789,12 +792,12 @@ def draw_idle(self):
789792
"""
790793
DEBUG_MSG("draw_idle()", 1, self)
791794
self._isDrawn = False # Force redraw
792-
795+
793796
# Triggering a paint event is all that is needed to defer drawing
794797
# until later. The platform will send the event when it thinks it is
795798
# a good time (usually as soon as there are no other events pending).
796799
self.Refresh(eraseBackground=False)
797-
800+
798801
def draw(self, drawDC=None):
799802
"""
800803
Render the figure using RendererWx instance renderer, or using a
@@ -1739,7 +1742,7 @@ def draw_rubberband(self, event, x0, y0, x1, y1):
17391742
color.Set(r,g,b, 0x60)
17401743
dc.SetBrush(wx.Brush(color))
17411744
dc.DrawRectangleRect(rect)
1742-
1745+
17431746

17441747
def set_status_bar(self, statbar):
17451748
self.statbar = statbar

lib/matplotlib/lines.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,7 @@ def set_linewidth(self, w):
919919
920920
ACCEPTS: float value in points
921921
"""
922-
self._linewidth = w
922+
self._linewidth = float(w)
923923

924924
def set_linestyle(self, linestyle):
925925
"""

lib/matplotlib/patches.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ def set_linewidth(self, w):
334334
"""
335335
if w is None:
336336
w = mpl.rcParams['patch.linewidth']
337-
self._linewidth = w
337+
self._linewidth = float(w)
338338

339339
def set_lw(self, lw):
340340
"""alias for set_linewidth"""

0 commit comments

Comments
 (0)