Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 22d98a8

Browse filesBrowse files
authored
Merge pull request #9236 from dopplershift/fix-9235
Fix fill_between with decreasing data
2 parents 1ef7c13 + 61f4fa3 commit 22d98a8
Copy full SHA for 22d98a8

File tree

Expand file treeCollapse file tree

5 files changed

+240
-2
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+240
-2
lines changed

‎lib/matplotlib/axes/_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_axes.py
+6-2Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4876,7 +4876,9 @@ def get_interp_point(ind):
48764876
diff_order = diff_values.argsort()
48774877
diff_root_x = np.interp(
48784878
0, diff_values[diff_order], x_values[diff_order])
4879-
diff_root_y = np.interp(diff_root_x, x_values, y1_values)
4879+
x_order = x_values.argsort()
4880+
diff_root_y = np.interp(diff_root_x, x_values[x_order],
4881+
y1_values[x_order])
48804882
return diff_root_x, diff_root_y
48814883

48824884
start = get_interp_point(ind0)
@@ -5026,7 +5028,9 @@ def get_interp_point(ind):
50265028
diff_order = diff_values.argsort()
50275029
diff_root_y = np.interp(
50285030
0, diff_values[diff_order], y_values[diff_order])
5029-
diff_root_x = np.interp(diff_root_y, y_values, x1_values)
5031+
y_order = y_values.argsort()
5032+
diff_root_x = np.interp(diff_root_y, y_values[y_order],
5033+
x1_values[y_order])
50305034
return diff_root_x, diff_root_y
50315035

50325036
start = get_interp_point(ind0)
Loading
+212Lines changed: 212 additions & 0 deletions
Loading

‎lib/matplotlib/tests/test_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_axes.py
+22Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -968,6 +968,28 @@ def test_fill_between_interpolate():
968968
interpolate=True)
969969

970970

971+
@image_comparison(baseline_images=['fill_between_interpolate_decreasing'],
972+
style='mpl20', remove_text=True)
973+
def test_fill_between_interpolate_decreasing():
974+
p = np.array([724.3, 700, 655])
975+
t = np.array([9.4, 7, 2.2])
976+
prof = np.array([7.9, 6.6, 3.8])
977+
978+
fig = plt.figure(figsize=(9, 9))
979+
ax = fig.add_subplot(1, 1, 1)
980+
981+
ax.plot(t, p, 'tab:red')
982+
ax.plot(prof, p, 'k')
983+
984+
ax.fill_betweenx(p, t, prof, where=prof < t,
985+
facecolor='blue', interpolate=True, alpha=0.4)
986+
ax.fill_betweenx(p, t, prof, where=prof > t,
987+
facecolor='red', interpolate=True, alpha=0.4)
988+
989+
ax.set_xlim(0, 30)
990+
ax.set_ylim(800, 600)
991+
992+
971993
@image_comparison(baseline_images=['symlog'])
972994
def test_symlog():
973995
x = np.array([0, 1, 2, 4, 6, 9, 12, 24])

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.