Skip to content

Commit

Permalink
Option to change background for plotted value tags for dark theme
Browse files Browse the repository at this point in the history
  • Loading branch information
WISEPLAT committed Sep 18, 2022
1 parent e2674b1 commit 77a7ce8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions backtrader/plot/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ class Plot_OldSync(with_metaclass(MetaParams, object)):
def __init__(self, **kwargs):
for pname, pvalue in kwargs.items():
setattr(self.p.scheme, pname, pvalue)
if not hasattr(self.p.scheme, 'locbg'):
setattr(self.p.scheme, 'locbg', 'white')
setattr(self.p.scheme, 'locbgother', 'white')

def drawtag(self, ax, x, y, facecolor, edgecolor, alpha=0.9, **kwargs):

Expand Down Expand Up @@ -487,7 +490,7 @@ def plotind(self, iref, ind,
if linetag and not math.isnan(lplot[-1]):
# line has valid values, plot a tag for the last value
self.drawtag(ax, len(self.pinf.xreal), lplot[-1],
facecolor='white',
facecolor=self.pinf.sch.locbgother,
edgecolor=self.pinf.color(ax))

farts = (('_gt', operator.gt), ('_lt', operator.lt), ('', None),)
Expand Down Expand Up @@ -732,7 +735,8 @@ def plotdata(self, data, indicators):
vtags = data.plotinfo._get('plotvaluetags', True)
if self.pinf.sch.valuetags and vtags:
self.drawtag(ax, len(self.pinf.xreal), closes[-1],
facecolor='white', edgecolor=self.pinf.sch.loc)
facecolor=self.pinf.sch.locbg,
edgecolor=self.pinf.sch.loc)

ax.yaxis.set_major_locator(mticker.MaxNLocator(prune='both'))
# make sure "over" indicators do not change our scale
Expand Down

0 comments on commit 77a7ce8

Please sign in to comment.