Test the label parameter. It should just be mapped to the xlabel/ylabel of the axes, depending on the orientation.
()
| 724 | |
| 725 | |
| 726 | def test_colorbar_label(): |
| 727 | """ |
| 728 | Test the label parameter. It should just be mapped to the xlabel/ylabel of |
| 729 | the axes, depending on the orientation. |
| 730 | """ |
| 731 | fig, ax = plt.subplots() |
| 732 | im = ax.imshow([[1, 2], [3, 4]]) |
| 733 | cbar = fig.colorbar(im, label='cbar') |
| 734 | assert cbar.ax.get_ylabel() == 'cbar' |
| 735 | cbar.set_label(None) |
| 736 | assert cbar.ax.get_ylabel() == '' |
| 737 | cbar.set_label('cbar 2') |
| 738 | assert cbar.ax.get_ylabel() == 'cbar 2' |
| 739 | |
| 740 | cbar2 = fig.colorbar(im, label=None) |
| 741 | assert cbar2.ax.get_ylabel() == '' |
| 742 | |
| 743 | cbar3 = fig.colorbar(im, orientation='horizontal', label='horizontal cbar') |
| 744 | assert cbar3.ax.get_xlabel() == 'horizontal cbar' |
| 745 | |
| 746 | |
| 747 | @image_comparison(['colorbar_keeping_xlabel.png'], style='mpl20') |
nothing calls this directly
no test coverage detected
searching dependent graphs…