| 621 | |
| 622 | |
| 623 | class GridlinesCollection(LineCollection): |
| 624 | def __init__(self, *args, which="major", axis="both", **kwargs): |
| 625 | """ |
| 626 | Collection of grid lines. |
| 627 | |
| 628 | Parameters |
| 629 | ---------- |
| 630 | which : {"major", "minor"} |
| 631 | Which grid to consider. |
| 632 | axis : {"both", "x", "y"} |
| 633 | Which axis to consider. |
| 634 | *args, **kwargs |
| 635 | Passed to `.LineCollection`. |
| 636 | """ |
| 637 | self._which = which |
| 638 | self._axis = axis |
| 639 | super().__init__(*args, **kwargs) |
| 640 | self.set_grid_helper(None) |
| 641 | |
| 642 | def set_which(self, which): |
| 643 | """ |
| 644 | Select major or minor grid lines. |
| 645 | |
| 646 | Parameters |
| 647 | ---------- |
| 648 | which : {"major", "minor"} |
| 649 | """ |
| 650 | self._which = which |
| 651 | |
| 652 | def set_axis(self, axis): |
| 653 | """ |
| 654 | Select axis. |
| 655 | |
| 656 | Parameters |
| 657 | ---------- |
| 658 | axis : {"both", "x", "y"} |
| 659 | """ |
| 660 | self._axis = axis |
| 661 | |
| 662 | def set_grid_helper(self, grid_helper): |
| 663 | """ |
| 664 | Set grid helper. |
| 665 | |
| 666 | Parameters |
| 667 | ---------- |
| 668 | grid_helper : `.GridHelperBase` subclass |
| 669 | """ |
| 670 | self._grid_helper = grid_helper |
| 671 | |
| 672 | def draw(self, renderer): |
| 673 | if self._grid_helper is not None: |
| 674 | self._grid_helper.update_lim(self.axes) |
| 675 | gl = self._grid_helper.get_gridlines(self._which, self._axis) |
| 676 | self.set_segments([np.transpose(l) for l in gl]) |
| 677 | super().draw(renderer) |
| 678 | |
| 679 | |
| 680 | class AxisArtist(martist.Artist): |
no outgoing calls
no test coverage detected
searching dependent graphs…