@@ -67,6 +67,7 @@ def __init__(self):
6767 self .msg = "Initialized PlotlyRenderer\n "
6868 self ._processing_legend = False
6969 self ._legend_visible = False
70+ self .axes_list = []
7071
7172 def _convert_x_dates (self , x ):
7273 """Convert x values to date strings when the x-axis is a date axis."""
@@ -167,8 +168,8 @@ def open_axes(self, ax, props):
167168 ]
168169 self .current_bars = []
169170 self .axis_ct += 1
170- # update plot background with the axes background from mpl
171- self .plotly_fig ["layout" ].plot_bgcolor = _export_color (props ["axesbg" ])
171+ if props . get ( "patch_visible" , True ):
172+ self .plotly_fig ["layout" ].plot_bgcolor = _export_color (props ["axesbg" ])
172173 # set defaults in axes
173174 xaxis = go .layout .XAxis (
174175 anchor = "y{0}" .format (self .axis_ct ), zeroline = False , ticks = "inside"
@@ -223,6 +224,36 @@ def open_axes(self, ax, props):
223224 if not y_main_ticks :
224225 yaxis ["ticks" ] = ""
225226
227+ overlay_ax_ct = None
228+ for prev_ax , prev_ct in self .axes_list :
229+ is_twinned = (
230+ (
231+ hasattr (ax , "_twinned_axes" )
232+ and ax in ax ._twinned_axes .get_siblings (prev_ax )
233+ )
234+ or getattr (ax , "_sharex" , None ) == prev_ax
235+ or getattr (ax , "_sharey" , None ) == prev_ax
236+ or getattr (prev_ax , "_sharex" , None ) == ax
237+ or getattr (prev_ax , "_sharey" , None ) == ax
238+ or (ax .get_position ().bounds == prev_ax .get_position ().bounds )
239+ )
240+ if is_twinned :
241+ overlay_ax_ct = prev_ct
242+ break
243+
244+ if overlay_ax_ct is not None :
245+ overlay_x = "x" if overlay_ax_ct == 1 else "x{0}" .format (overlay_ax_ct )
246+ overlay_y = "y" if overlay_ax_ct == 1 else "y{0}" .format (overlay_ax_ct )
247+ xaxis ["overlaying" ] = overlay_x
248+ yaxis ["overlaying" ] = overlay_y
249+
250+ if not props ["axes" ][0 ]["visible" ]:
251+ xaxis ["visible" ] = False
252+ if not props ["axes" ][1 ]["visible" ]:
253+ yaxis ["visible" ] = False
254+
255+ self .axes_list .append ((ax , self .axis_ct ))
256+
226257 # put axes in our figure
227258 self .plotly_fig ["layout" ]["xaxis{0}" .format (self .axis_ct )] = xaxis
228259 self .plotly_fig ["layout" ]["yaxis{0}" .format (self .axis_ct )] = yaxis
0 commit comments