Skip to content

Commit 72ba422

Browse files
committed
Fix color assignments, ticks line widths and some pep-8 improvements
1 parent ba336a0 commit 72ba422

1 file changed

Lines changed: 11 additions & 13 deletions

File tree

backtrader/plot/finance.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
import matplotlib.colors as mcolors
2828
import matplotlib.legend as mlegend
2929
import matplotlib.lines as mlines
30-
import matplotlib.patches as mpatches
31-
import matplotlib.transforms as mtransforms
3230

3331
from .utils import shade_color
3432

@@ -134,9 +132,9 @@ def barcollection(self,
134132
**kwargs):
135133

136134
# Prepack different zips of the series values
137-
oc = lambda: zip(opens, closes)
138-
xoc = lambda: zip(xs, opens, closes)
139-
iohlc = lambda: zip(xs, opens, highs, lows, closes)
135+
oc = lambda: zip(opens, closes) # NOQA: E731
136+
xoc = lambda: zip(xs, opens, closes) # NOQA: E731
137+
iohlc = lambda: zip(xs, opens, highs, lows, closes) # NOQA: E731
140138

141139
colorup = self.colorup if fillup else 'None'
142140
colordown = self.colordown if filldown else 'None'
@@ -147,7 +145,7 @@ def barcollection(self,
147145
edgecolors = [edgecolord[o < c] for o, c in oc()]
148146

149147
tickcolord = {True: self.tickup, False: self.tickdown}
150-
tickcolors = [edgecolord[o < c] for o, c in oc()]
148+
tickcolors = [tickcolord[o < c] for o, c in oc()]
151149

152150
delta = width / 2 - edgeadjust
153151

@@ -313,7 +311,7 @@ def barcollection(self,
313311
**kwargs):
314312

315313
# Prepare the data
316-
openclose = lambda: zip(opens, closes)
314+
openclose = lambda: zip(opens, closes) # NOQA: E731
317315

318316
# Calculate bars colors
319317
colord = {True: self.colorup, False: self.colordown}
@@ -437,10 +435,10 @@ def barcollection(self,
437435
**kwargs):
438436

439437
# Prepack different zips of the series values
440-
ihighlow = lambda: zip(xs, highs, lows)
441-
iopen = lambda: zip(xs, opens)
442-
iclose = lambda: zip(xs, closes)
443-
openclose = lambda: zip(opens, closes)
438+
ihighlow = lambda: zip(xs, highs, lows) # NOQA: E731
439+
iopen = lambda: zip(xs, opens) # NOQA: E731
440+
iclose = lambda: zip(xs, closes) # NOQA: E731
441+
openclose = lambda: zip(opens, closes) # NOQA: E731
444442

445443
colord = {True: self.colorup, False: self.colordown}
446444
colors = [colord[open < close] for open, close in openclose()]
@@ -473,7 +471,7 @@ def tickopen(i, open):
473471
openticks,
474472
colors=colors,
475473
antialiaseds=useaa,
476-
linewidths=lw,
474+
linewidths=tlw,
477475
label='_nolegend',
478476
**kwargs)
479477

@@ -486,7 +484,7 @@ def tickclose(i, close):
486484
closeticks,
487485
colors=colors,
488486
antialiaseds=useaa,
489-
linewidths=lw,
487+
linewidths=tlw,
490488
label='_nolegend',
491489
**kwargs)
492490

0 commit comments

Comments
 (0)