@@ -160,6 +160,8 @@ def _init3d(self):
160160 self .axes ._set_artist_props (self .pane )
161161 self .gridlines = art3d .Line3DCollection ([])
162162 self .axes ._set_artist_props (self .gridlines )
163+ self .minor_gridlines = art3d .Line3DCollection ([])
164+ self .axes ._set_artist_props (self .minor_gridlines )
163165 self .axes ._set_artist_props (self .label )
164166 self .axes ._set_artist_props (self .offsetText )
165167 # Need to be able to place the label at the correct location
@@ -678,6 +680,59 @@ def draw_grid(self, renderer):
678680
679681 renderer .close_group ('grid3d' )
680682
683+ @artist .allow_rasterization
684+ def draw_minor_grid (self , renderer ):
685+ if not getattr (self .axes , '_draw_minor_grid' , False ):
686+ return
687+
688+ renderer .open_group ("minor_grid3d" , gid = self .get_gid ())
689+
690+ minor_locs = self .get_minorticklocs ()
691+ if len (minor_locs ):
692+ info = self ._axinfo
693+ index = info ["i" ]
694+
695+ mins , maxs , tc , highs = self ._get_coord_info ()
696+ xlim , ylim , zlim = (self .axes .get_xbound (),
697+ self .axes .get_ybound (),
698+ self .axes .get_zbound ())
699+ data_mins = np .array ([xlim [0 ], ylim [0 ], zlim [0 ]])
700+ data_maxs = np .array ([xlim [1 ], ylim [1 ], zlim [1 ]])
701+ minmax = np .where (highs , data_maxs , data_mins )
702+ maxmin = np .where (~ highs , data_maxs , data_mins )
703+
704+ # Filter to ticks within view limits
705+ vmin , vmax = self .get_view_interval ()
706+ minor_locs = [t for t in minor_locs if vmin <= t <= vmax ]
707+
708+ if len (minor_locs ):
709+ xyz0 = np .tile (minmax , (len (minor_locs ), 1 ))
710+ xyz0 [:, index ] = minor_locs
711+
712+ lines = np .stack ([xyz0 , xyz0 , xyz0 ], axis = 1 )
713+ lines [:, 0 , index - 2 ] = maxmin [index - 2 ]
714+ lines [:, 2 , index - 1 ] = maxmin [index - 1 ]
715+
716+ self .minor_gridlines .set_segments (lines )
717+
718+ # Default minor style: thinner and more transparent than major
719+ gridinfo = info ['grid' ]
720+ minor_kw = {
721+ 'color' : gridinfo ['color' ],
722+ 'linewidth' : gridinfo ['linewidth' ] * 0.5 ,
723+ 'linestyle' : gridinfo ['linestyle' ],
724+ }
725+ # Apply any user overrides from ax.grid(which='minor', ...)
726+ minor_kw .update (getattr (self .axes , '_minor_grid_kwargs' , {}))
727+
728+ self .minor_gridlines .set_color (minor_kw ['color' ])
729+ self .minor_gridlines .set_linewidth (minor_kw ['linewidth' ])
730+ self .minor_gridlines .set_linestyle (minor_kw ['linestyle' ])
731+ self .minor_gridlines .do_3d_projection ()
732+ self .minor_gridlines .draw (renderer )
733+
734+ renderer .close_group ('minor_grid3d' )
735+
681736 # TODO: Get this to work (more) properly when mplot3d supports the
682737 # transforms framework.
683738 def get_tightbbox (self , renderer = None , * , for_layout_only = False ):
0 commit comments