Skip to content

Commit 50e816e

Browse files
set axisbelow so grid does not show through
1 parent 50df2ef commit 50e816e

File tree

3 files changed

+28
-53
lines changed

3 files changed

+28
-53
lines changed

examples/scratch_pad/issues/Issue156_title_ruins_tight_layout.ipynb

Lines changed: 21 additions & 52 deletions
Large diffs are not rendered by default.

src/mplfinance/_panels.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,15 @@ def _build_panels( figure, config ):
156156
lift = panels['height'].loc[panid+1:].sum()
157157
panels.at[panid,'lift'] = lift
158158
if panid == 0:
159+
# rect = [left, bottom, width, height]
159160
ax0 = figure.add_axes( [0.15, 0.18+lift, 0.70, height] )
160161
else:
161162
ax0 = figure.add_axes( [0.15, 0.18+lift, 0.70, height], sharex=panels.at[0,'axes'][0] )
162163
ax1 = ax0.twinx()
163164
ax1.grid(False)
164-
if panid == volume_panel:
165+
if config['saxbelow']: # issue#115 issuecomment-639446764
166+
ax0.set_axisbelow(True) # so grid does not show through plot data on any panel.
167+
elif panid == volume_panel:
165168
ax0.set_axisbelow(True) # so grid does not show through volume bars.
166169
panels.at[panid,'axes'] = (ax0,ax1)
167170

src/mplfinance/plotting.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,9 @@ def _valid_plot_kwargs():
223223

224224
'return_width_config' : { 'Default' : None,
225225
'Validator' : lambda value: isinstance(value,dict) and len(value)==0 },
226+
227+
'saxbelow' : { 'Default' : True, # Issue#115 Comment#639446764
228+
'Validator' : lambda value: isinstance(value,bool) },
226229
}
227230

228231
_validate_vkwargs_dict(vkwargs)

0 commit comments

Comments
 (0)