From c66fd4685115023cc07748fc18a722314d6aa514 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Fri, 24 Sep 2021 16:18:01 +0200 Subject: [PATCH] Cleanup contour(f)3d examples. Axes3D.clabel is a noop, so don't use it in examples (perhaps it should in fact throw a NotImplementedError, but let's not worry about that here). Various other small cleanups. --- examples/mplot3d/contour3d.py | 3 +-- examples/mplot3d/contour3d_2.py | 5 +---- examples/mplot3d/contour3d_3.py | 19 +++++++------------ examples/mplot3d/contourf3d.py | 5 +---- examples/mplot3d/contourf3d_2.py | 15 +++++---------- 5 files changed, 15 insertions(+), 32 deletions(-) diff --git a/examples/mplot3d/contour3d.py b/examples/mplot3d/contour3d.py index 7c4f5dcbc6d5..2b0a2872d0cc 100644 --- a/examples/mplot3d/contour3d.py +++ b/examples/mplot3d/contour3d.py @@ -14,7 +14,6 @@ ax = plt.figure().add_subplot(projection='3d') X, Y, Z = axes3d.get_test_data(0.05) -cset = ax.contour(X, Y, Z, cmap=cm.coolwarm) # Plot contour curves -ax.clabel(cset, fontsize=9, inline=True) +ax.contour(X, Y, Z, cmap=cm.coolwarm) # Plot contour curves plt.show() diff --git a/examples/mplot3d/contour3d_2.py b/examples/mplot3d/contour3d_2.py index ed9c27f0b5ab..b6478bc79142 100644 --- a/examples/mplot3d/contour3d_2.py +++ b/examples/mplot3d/contour3d_2.py @@ -13,9 +13,6 @@ ax = plt.figure().add_subplot(projection='3d') X, Y, Z = axes3d.get_test_data(0.05) - -cset = ax.contour(X, Y, Z, extend3d=True, cmap=cm.coolwarm) - -ax.clabel(cset, fontsize=9, inline=True) +ax.contour(X, Y, Z, extend3d=True, cmap=cm.coolwarm) plt.show() diff --git a/examples/mplot3d/contour3d_3.py b/examples/mplot3d/contour3d_3.py index db620e426a68..4b8c5ed77d71 100644 --- a/examples/mplot3d/contour3d_3.py +++ b/examples/mplot3d/contour3d_3.py @@ -21,17 +21,12 @@ # Plot projections of the contours for each dimension. By choosing offsets # that match the appropriate axes limits, the projected contours will sit on -# the 'walls' of the graph -cset = ax.contour(X, Y, Z, zdir='z', offset=-100, cmap=cm.coolwarm) -cset = ax.contour(X, Y, Z, zdir='x', offset=-40, cmap=cm.coolwarm) -cset = ax.contour(X, Y, Z, zdir='y', offset=40, cmap=cm.coolwarm) - -ax.set_xlim(-40, 40) -ax.set_ylim(-40, 40) -ax.set_zlim(-100, 100) - -ax.set_xlabel('X') -ax.set_ylabel('Y') -ax.set_zlabel('Z') +# the 'walls' of the graph. +ax.contour(X, Y, Z, zdir='z', offset=-100, cmap=cm.coolwarm) +ax.contour(X, Y, Z, zdir='x', offset=-40, cmap=cm.coolwarm) +ax.contour(X, Y, Z, zdir='y', offset=40, cmap=cm.coolwarm) + +ax.set(xlim=(-40, 40), ylim=(-40, 40), zlim=(-100, 100), + xlabel='X', ylabel='Y', zlabel='Z') plt.show() diff --git a/examples/mplot3d/contourf3d.py b/examples/mplot3d/contourf3d.py index 7cb78e8f1b52..c15ecdcfd6c0 100644 --- a/examples/mplot3d/contourf3d.py +++ b/examples/mplot3d/contourf3d.py @@ -16,9 +16,6 @@ ax = plt.figure().add_subplot(projection='3d') X, Y, Z = axes3d.get_test_data(0.05) - -cset = ax.contourf(X, Y, Z, cmap=cm.coolwarm) - -ax.clabel(cset, fontsize=9, inline=True) +ax.contourf(X, Y, Z, cmap=cm.coolwarm) plt.show() diff --git a/examples/mplot3d/contourf3d_2.py b/examples/mplot3d/contourf3d_2.py index 5ef9dc8761c7..e550d0ee5933 100644 --- a/examples/mplot3d/contourf3d_2.py +++ b/examples/mplot3d/contourf3d_2.py @@ -22,16 +22,11 @@ # Plot projections of the contours for each dimension. By choosing offsets # that match the appropriate axes limits, the projected contours will sit on # the 'walls' of the graph -cset = ax.contourf(X, Y, Z, zdir='z', offset=-100, cmap=cm.coolwarm) -cset = ax.contourf(X, Y, Z, zdir='x', offset=-40, cmap=cm.coolwarm) -cset = ax.contourf(X, Y, Z, zdir='y', offset=40, cmap=cm.coolwarm) +ax.contourf(X, Y, Z, zdir='z', offset=-100, cmap=cm.coolwarm) +ax.contourf(X, Y, Z, zdir='x', offset=-40, cmap=cm.coolwarm) +ax.contourf(X, Y, Z, zdir='y', offset=40, cmap=cm.coolwarm) -ax.set_xlim(-40, 40) -ax.set_ylim(-40, 40) -ax.set_zlim(-100, 100) - -ax.set_xlabel('X') -ax.set_ylabel('Y') -ax.set_zlabel('Z') +ax.set(xlim=(-40, 40), ylim=(-40, 40), zlim=(-100, 100), + xlabel='X', ylabel='Y', zlabel='Z') plt.show()