(self, renderer)
| 636 | |
| 637 | @artist.allow_rasterization |
| 638 | def draw_grid(self, renderer): |
| 639 | if not self.axes._draw_grid: |
| 640 | return |
| 641 | |
| 642 | renderer.open_group("grid3d", gid=self.get_gid()) |
| 643 | |
| 644 | ticks = self._update_ticks() |
| 645 | if len(ticks): |
| 646 | # Get general axis information: |
| 647 | info = self._axinfo |
| 648 | index = info["i"] |
| 649 | |
| 650 | # Grid lines use data-space bounds (Line3DCollection applies transforms) |
| 651 | mins, maxs, tc, highs = self._get_coord_info() |
| 652 | xlim, ylim, zlim = (self.axes.get_xbound(), |
| 653 | self.axes.get_ybound(), |
| 654 | self.axes.get_zbound()) |
| 655 | data_mins = np.array([xlim[0], ylim[0], zlim[0]]) |
| 656 | data_maxs = np.array([xlim[1], ylim[1], zlim[1]]) |
| 657 | minmax = np.where(highs, data_maxs, data_mins) |
| 658 | maxmin = np.where(~highs, data_maxs, data_mins) |
| 659 | |
| 660 | # Grid points where the planes meet |
| 661 | xyz0 = np.tile(minmax, (len(ticks), 1)) |
| 662 | xyz0[:, index] = [tick.get_loc() for tick in ticks] |
| 663 | |
| 664 | # Grid lines go from the end of one plane through the plane |
| 665 | # intersection (at xyz0) to the end of the other plane. The first |
| 666 | # point (0) differs along dimension index-2 and the last (2) along |
| 667 | # dimension index-1. |
| 668 | lines = np.stack([xyz0, xyz0, xyz0], axis=1) |
| 669 | lines[:, 0, index - 2] = maxmin[index - 2] |
| 670 | lines[:, 2, index - 1] = maxmin[index - 1] |
| 671 | self.gridlines.set_segments(lines) |
| 672 | gridinfo = info['grid'] |
| 673 | self.gridlines.set_color(gridinfo['color']) |
| 674 | self.gridlines.set_linewidth(gridinfo['linewidth']) |
| 675 | self.gridlines.set_linestyle(gridinfo['linestyle']) |
| 676 | self.gridlines.do_3d_projection() |
| 677 | self.gridlines.draw(renderer) |
| 678 | |
| 679 | renderer.close_group('grid3d') |
| 680 | |
| 681 | # TODO: Get this to work (more) properly when mplot3d supports the |
| 682 | # transforms framework. |
no test coverage detected