From 5f67a3d70ce3706aece82cf6ad9ae93d28ece0b6 Mon Sep 17 00:00:00 2001 From: baharev Date: Sun, 18 Sep 2022 13:11:49 +0200 Subject: [PATCH 1/3] Fix edge color, links, wording; closes matplotlib/matplotlib#23895 --- examples/mplot3d/contour3d_3.py | 10 +++++----- examples/mplot3d/contourf3d_2.py | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/mplot3d/contour3d_3.py b/examples/mplot3d/contour3d_3.py index 4b8c5ed77d71..264b549d3bdb 100644 --- a/examples/mplot3d/contour3d_3.py +++ b/examples/mplot3d/contour3d_3.py @@ -1,12 +1,12 @@ """ -======================================== -Projecting contour profiles onto a graph -======================================== +===================================== +Project contour profiles onto a graph +===================================== Demonstrates displaying a 3D surface while also projecting contour 'profiles' onto the 'walls' of the graph. -See contourf3d_demo2 for the filled version. +See :doc:`contourf3d_2` for the filled version. """ from mpl_toolkits.mplot3d import axes3d @@ -17,7 +17,7 @@ X, Y, Z = axes3d.get_test_data(0.05) # Plot the 3D surface -ax.plot_surface(X, Y, Z, rstride=8, cstride=8, alpha=0.3) +ax.plot_surface(X, Y, Z, edgecolor='black', rstride=8, cstride=8, alpha=0.3) # Plot projections of the contours for each dimension. By choosing offsets # that match the appropriate axes limits, the projected contours will sit on diff --git a/examples/mplot3d/contourf3d_2.py b/examples/mplot3d/contourf3d_2.py index e550d0ee5933..220147a2ad08 100644 --- a/examples/mplot3d/contourf3d_2.py +++ b/examples/mplot3d/contourf3d_2.py @@ -1,12 +1,12 @@ """ -====================================== -Projecting filled contour onto a graph -====================================== +=================================== +Project filled contour onto a graph +=================================== Demonstrates displaying a 3D surface while also projecting filled contour 'profiles' onto the 'walls' of the graph. -See contour3d_demo2 for the unfilled version. +See :doc:`contour3d_3` for the unfilled version. """ from mpl_toolkits.mplot3d import axes3d @@ -17,7 +17,7 @@ X, Y, Z = axes3d.get_test_data(0.05) # Plot the 3D surface -ax.plot_surface(X, Y, Z, rstride=8, cstride=8, alpha=0.3) +ax.plot_surface(X, Y, Z, edgecolor='black', rstride=8, cstride=8, alpha=0.3) # Plot projections of the contours for each dimension. By choosing offsets # that match the appropriate axes limits, the projected contours will sit on From 85e6634134510e7d968212e23258368b45c1eacf Mon Sep 17 00:00:00 2001 From: baharev Date: Mon, 19 Sep 2022 21:19:48 +0200 Subject: [PATCH 2/3] Changing the edge color and the line width in response to the comments --- examples/mplot3d/contour3d_3.py | 11 ++++++----- examples/mplot3d/contourf3d_2.py | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/examples/mplot3d/contour3d_3.py b/examples/mplot3d/contour3d_3.py index 264b549d3bdb..da67d5cac430 100644 --- a/examples/mplot3d/contour3d_3.py +++ b/examples/mplot3d/contour3d_3.py @@ -11,20 +11,21 @@ from mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot as plt -from matplotlib import cm +from matplotlib.cm import coolwarm as cmap ax = plt.figure().add_subplot(projection='3d') X, Y, Z = axes3d.get_test_data(0.05) # Plot the 3D surface -ax.plot_surface(X, Y, Z, edgecolor='black', rstride=8, cstride=8, alpha=0.3) +ax.plot_surface(X, Y, Z, edgecolor=cmap(0), lw=0.5, rstride=8, cstride=8, + alpha=0.3) # 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. -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.contour(X, Y, Z, zdir='z', offset=-100, cmap=cmap) +ax.contour(X, Y, Z, zdir='x', offset=-40, cmap=cmap) +ax.contour(X, Y, Z, zdir='y', offset=40, cmap=cmap) ax.set(xlim=(-40, 40), ylim=(-40, 40), zlim=(-100, 100), xlabel='X', ylabel='Y', zlabel='Z') diff --git a/examples/mplot3d/contourf3d_2.py b/examples/mplot3d/contourf3d_2.py index 220147a2ad08..dc5c8af3805e 100644 --- a/examples/mplot3d/contourf3d_2.py +++ b/examples/mplot3d/contourf3d_2.py @@ -11,20 +11,21 @@ from mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot as plt -from matplotlib import cm +from matplotlib.cm import coolwarm as cmap ax = plt.figure().add_subplot(projection='3d') X, Y, Z = axes3d.get_test_data(0.05) # Plot the 3D surface -ax.plot_surface(X, Y, Z, edgecolor='black', rstride=8, cstride=8, alpha=0.3) +ax.plot_surface(X, Y, Z, edgecolor=cmap(0), lw=0.5, rstride=8, cstride=8, + alpha=0.3) # 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 -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.contourf(X, Y, Z, zdir='z', offset=-100, cmap=cmap) +ax.contourf(X, Y, Z, zdir='x', offset=-40, cmap=cmap) +ax.contourf(X, Y, Z, zdir='y', offset=40, cmap=cmap) ax.set(xlim=(-40, 40), ylim=(-40, 40), zlim=(-100, 100), xlabel='X', ylabel='Y', zlabel='Z') From ff7c43aa406ab1a922a9a4b396310ba7a89b6bf9 Mon Sep 17 00:00:00 2001 From: baharev Date: Tue, 20 Sep 2022 09:58:28 +0200 Subject: [PATCH 3/3] Specifying the color map and the edge color as strings --- examples/mplot3d/contour3d_3.py | 11 ++++------- examples/mplot3d/contourf3d_2.py | 11 ++++------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/examples/mplot3d/contour3d_3.py b/examples/mplot3d/contour3d_3.py index da67d5cac430..c6a599328697 100644 --- a/examples/mplot3d/contour3d_3.py +++ b/examples/mplot3d/contour3d_3.py @@ -2,30 +2,27 @@ ===================================== Project contour profiles onto a graph ===================================== - Demonstrates displaying a 3D surface while also projecting contour 'profiles' onto the 'walls' of the graph. - See :doc:`contourf3d_2` for the filled version. """ from mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot as plt -from matplotlib.cm import coolwarm as cmap ax = plt.figure().add_subplot(projection='3d') X, Y, Z = axes3d.get_test_data(0.05) # Plot the 3D surface -ax.plot_surface(X, Y, Z, edgecolor=cmap(0), lw=0.5, rstride=8, cstride=8, +ax.plot_surface(X, Y, Z, edgecolor='royalblue', lw=0.5, rstride=8, cstride=8, alpha=0.3) # 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. -ax.contour(X, Y, Z, zdir='z', offset=-100, cmap=cmap) -ax.contour(X, Y, Z, zdir='x', offset=-40, cmap=cmap) -ax.contour(X, Y, Z, zdir='y', offset=40, cmap=cmap) +ax.contour(X, Y, Z, zdir='z', offset=-100, cmap='coolwarm') +ax.contour(X, Y, Z, zdir='x', offset=-40, cmap='coolwarm') +ax.contour(X, Y, Z, zdir='y', offset=40, cmap='coolwarm') ax.set(xlim=(-40, 40), ylim=(-40, 40), zlim=(-100, 100), xlabel='X', ylabel='Y', zlabel='Z') diff --git a/examples/mplot3d/contourf3d_2.py b/examples/mplot3d/contourf3d_2.py index dc5c8af3805e..d0cb6d4ab79c 100644 --- a/examples/mplot3d/contourf3d_2.py +++ b/examples/mplot3d/contourf3d_2.py @@ -2,30 +2,27 @@ =================================== Project filled contour onto a graph =================================== - Demonstrates displaying a 3D surface while also projecting filled contour 'profiles' onto the 'walls' of the graph. - See :doc:`contour3d_3` for the unfilled version. """ from mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot as plt -from matplotlib.cm import coolwarm as cmap ax = plt.figure().add_subplot(projection='3d') X, Y, Z = axes3d.get_test_data(0.05) # Plot the 3D surface -ax.plot_surface(X, Y, Z, edgecolor=cmap(0), lw=0.5, rstride=8, cstride=8, +ax.plot_surface(X, Y, Z, edgecolor='royalblue', lw=0.5, rstride=8, cstride=8, alpha=0.3) # 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 -ax.contourf(X, Y, Z, zdir='z', offset=-100, cmap=cmap) -ax.contourf(X, Y, Z, zdir='x', offset=-40, cmap=cmap) -ax.contourf(X, Y, Z, zdir='y', offset=40, cmap=cmap) +ax.contourf(X, Y, Z, zdir='z', offset=-100, cmap='coolwarm') +ax.contourf(X, Y, Z, zdir='x', offset=-40, cmap='coolwarm') +ax.contourf(X, Y, Z, zdir='y', offset=40, cmap='coolwarm') ax.set(xlim=(-40, 40), ylim=(-40, 40), zlim=(-100, 100), xlabel='X', ylabel='Y', zlabel='Z')