| 110 | |
| 111 | |
| 112 | def test_contour_manual_moveto(): |
| 113 | x = np.linspace(-10, 10) |
| 114 | y = np.linspace(-10, 10) |
| 115 | |
| 116 | X, Y = np.meshgrid(x, y) |
| 117 | |
| 118 | Z = X**2 * 1 / Y**2 - 1 |
| 119 | |
| 120 | contours = plt.contour(X, Y, Z, levels=[0, 100]) |
| 121 | |
| 122 | # This point lies on the `MOVETO` line for the 100 contour |
| 123 | # but is actually closest to the 0 contour |
| 124 | point = (1.3, 1) |
| 125 | clabels = plt.clabel(contours, manual=[point]) |
| 126 | |
| 127 | # Ensure that the 0 contour was chosen, not the 100 contour |
| 128 | assert clabels[0].get_text() == "0" |
| 129 | |
| 130 | |
| 131 | @image_comparison(['contour_disconnected_segments.png'], |