diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 48126b6be55e..688f70504233 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -4876,7 +4876,9 @@ def get_interp_point(ind): diff_order = diff_values.argsort() diff_root_x = np.interp( 0, diff_values[diff_order], x_values[diff_order]) - diff_root_y = np.interp(diff_root_x, x_values, y1_values) + x_order = x_values.argsort() + diff_root_y = np.interp(diff_root_x, x_values[x_order], + y1_values[x_order]) return diff_root_x, diff_root_y start = get_interp_point(ind0) @@ -5026,7 +5028,9 @@ def get_interp_point(ind): diff_order = diff_values.argsort() diff_root_y = np.interp( 0, diff_values[diff_order], y_values[diff_order]) - diff_root_x = np.interp(diff_root_y, y_values, x1_values) + y_order = y_values.argsort() + diff_root_x = np.interp(diff_root_y, y_values[y_order], + x1_values[y_order]) return diff_root_x, diff_root_y start = get_interp_point(ind0) diff --git a/lib/matplotlib/tests/baseline_images/test_axes/fill_between_interpolate_decreasing.pdf b/lib/matplotlib/tests/baseline_images/test_axes/fill_between_interpolate_decreasing.pdf new file mode 100644 index 000000000000..4042ec1c9fba Binary files /dev/null and b/lib/matplotlib/tests/baseline_images/test_axes/fill_between_interpolate_decreasing.pdf differ diff --git a/lib/matplotlib/tests/baseline_images/test_axes/fill_between_interpolate_decreasing.png b/lib/matplotlib/tests/baseline_images/test_axes/fill_between_interpolate_decreasing.png new file mode 100644 index 000000000000..c8bd0f845ca0 Binary files /dev/null and b/lib/matplotlib/tests/baseline_images/test_axes/fill_between_interpolate_decreasing.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_axes/fill_between_interpolate_decreasing.svg b/lib/matplotlib/tests/baseline_images/test_axes/fill_between_interpolate_decreasing.svg new file mode 100644 index 000000000000..857e8c92f833 --- /dev/null +++ b/lib/matplotlib/tests/baseline_images/test_axes/fill_between_interpolate_decreasing.svg @@ -0,0 +1,212 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 7d9b5d8639f0..0c22740a4f09 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -968,6 +968,28 @@ def test_fill_between_interpolate(): interpolate=True) +@image_comparison(baseline_images=['fill_between_interpolate_decreasing'], + style='mpl20', remove_text=True) +def test_fill_between_interpolate_decreasing(): + p = np.array([724.3, 700, 655]) + t = np.array([9.4, 7, 2.2]) + prof = np.array([7.9, 6.6, 3.8]) + + fig = plt.figure(figsize=(9, 9)) + ax = fig.add_subplot(1, 1, 1) + + ax.plot(t, p, 'tab:red') + ax.plot(prof, p, 'k') + + ax.fill_betweenx(p, t, prof, where=prof < t, + facecolor='blue', interpolate=True, alpha=0.4) + ax.fill_betweenx(p, t, prof, where=prof > t, + facecolor='red', interpolate=True, alpha=0.4) + + ax.set_xlim(0, 30) + ax.set_ylim(800, 600) + + @image_comparison(baseline_images=['symlog']) def test_symlog(): x = np.array([0, 1, 2, 4, 6, 9, 12, 24])