@@ -106,35 +106,61 @@ def _convert_x_dates(self, x):
106106 x = mpltools .mpl_dates_to_datestrings (x , formatter )
107107 return x
108108
109- def _open_polar_axes (self , ax ):
109+ def _open_polar_axes (self , ax , props ):
110110 """Create a plotly polar layout object for a matplotlib polar axes.
111111
112112 matplotlib polar data coordinates are (theta, r) with theta in
113113 radians measured from the positive x-axis (east). Plotly angular
114114 values are in degrees, with the rotation property setting the
115115 position of angular value 0 and direction setting the direction
116116 of positive angles, so both are taken from the matplotlib axes
117- to map the two coordinate systems onto each other.
117+ to map the two coordinate systems onto each other. Background,
118+ grid, and frame colors are taken from the matplotlib axes like
119+ they are for cartesian axes.
118120 """
119121 self .polar_ct += 1
120122 self .current_polar_subplot = (
121123 "polar{0}" .format (self .polar_ct ) if self .polar_ct > 1 else "polar"
122124 )
123125 theta_offset = ax .get_theta_offset ()
124126 theta_direction = ax .get_theta_direction ()
127+ angular_gridlines = ax .xaxis .get_gridlines ()
128+ radial_gridlines = ax .yaxis .get_gridlines ()
129+ angular_grid = (
130+ (angular_gridlines [0 ].get_color (), angular_gridlines [0 ].get_visible ())
131+ if len (angular_gridlines )
132+ else ("#b0b0b0" , True )
133+ )
134+ radial_grid = (
135+ (radial_gridlines [0 ].get_color (), radial_gridlines [0 ].get_visible ())
136+ if len (radial_gridlines )
137+ else ("#b0b0b0" , True )
138+ )
139+ frame = ax .spines .get ("polar" )
125140 self .plotly_fig ["layout" ][self .current_polar_subplot ] = go .layout .Polar (
141+ bgcolor = _export_color (props ["axesbg" ]),
126142 angularaxis = dict (
127143 rotation = float (np .degrees (theta_offset )),
128- direction = (
129- "counterclockwise" if theta_direction >= 0 else "clockwise"
130- ),
144+ direction = ("counterclockwise" if theta_direction >= 0 else "clockwise" ),
131145 tickvals = [float (t ) for t in np .degrees (ax .xaxis .get_majorticklocs ())],
132146 ticktext = [t .get_text () for t in ax .xaxis .get_majorticklabels ()],
147+ showgrid = angular_grid [1 ],
148+ gridcolor = _export_color (angular_grid [0 ]),
149+ showline = frame .get_visible () if frame is not None else True ,
150+ linecolor = (
151+ _export_color (frame .get_edgecolor ())
152+ if frame is not None
153+ else "black"
154+ ),
155+ linewidth = frame .get_linewidth () if frame is not None else 1 ,
133156 ),
134157 radialaxis = dict (
135158 range = [float (v ) for v in ax .get_ylim ()],
136159 tickvals = [float (t ) for t in ax .yaxis .get_majorticklocs ()],
137160 ticktext = [t .get_text () for t in ax .yaxis .get_majorticklabels ()],
161+ showgrid = radial_grid [1 ],
162+ gridcolor = _export_color (radial_grid [0 ]),
163+ showline = False ,
138164 ),
139165 )
140166
@@ -234,7 +260,7 @@ def open_axes(self, ax, props):
234260 self .current_is_polar = getattr (ax , "name" , None ) == "polar"
235261 if self .current_is_polar :
236262 self .msg += " Opening polar axes\n "
237- self ._open_polar_axes (ax )
263+ self ._open_polar_axes (ax , props )
238264 return
239265 self .axis_ct += 1
240266 if props .get ("patch_visible" , True ):
0 commit comments