From b0aaeb7dd657ace4c1f888f32716b47f0fcf4bc1 Mon Sep 17 00:00:00 2001 From: Gautam Sagar <47146980+gautamsagar99@users.noreply.github.com> Date: Sat, 26 Aug 2023 19:29:20 +0000 Subject: [PATCH 1/8] Removed unnecessary origin keywords --- .../images_contours_and_fields/contourf_demo.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/galleries/examples/images_contours_and_fields/contourf_demo.py b/galleries/examples/images_contours_and_fields/contourf_demo.py index edf72d928270..0b204fb022b6 100644 --- a/galleries/examples/images_contours_and_fields/contourf_demo.py +++ b/galleries/examples/images_contours_and_fields/contourf_demo.py @@ -8,7 +8,6 @@ import matplotlib.pyplot as plt import numpy as np -origin = 'lower' delta = 0.025 @@ -41,14 +40,14 @@ # for purposes of illustration. fig1, ax2 = plt.subplots(layout='constrained') -CS = ax2.contourf(X, Y, Z, 10, cmap=plt.cm.bone, origin=origin) +CS = ax2.contourf(X, Y, Z, 10, cmap=plt.cm.bone) # Note that in the following, we explicitly pass in a subset of the contour # levels used for the filled contours. Alternatively, we could pass in # additional levels to provide extra resolution, or leave out the *levels* # keyword argument to use all of the original levels. -CS2 = ax2.contour(CS, levels=CS.levels[::2], colors='r', origin=origin) +CS2 = ax2.contour(CS, levels=CS.levels[::2], colors='r') ax2.set_title('Nonsense (3 masked regions)') ax2.set_xlabel('word length anomaly') @@ -70,7 +69,6 @@ levels = [-1.5, -1, -0.5, 0, 0.5, 1] CS3 = ax2.contourf(X, Y, Z, levels, colors=('r', 'g', 'b'), - origin=origin, extend='both') # Our data range extends outside the range of levels; make # data below the lowest contour level yellow, and above the @@ -80,8 +78,8 @@ CS4 = ax2.contour(X, Y, Z, levels, colors=('k',), - linewidths=(3,), - origin=origin) + linewidths=(3,) + ) ax2.set_title('Listed colors (3 masked regions)') ax2.clabel(CS4, fmt='%2.1f', colors='w', fontsize=14) @@ -104,7 +102,7 @@ fig, axs = plt.subplots(2, 2, layout="constrained") for ax, extend in zip(axs.flat, extends): - cs = ax.contourf(X, Y, Z, levels, cmap=cmap, extend=extend, origin=origin) + cs = ax.contourf(X, Y, Z, levels, cmap=cmap, extend=extend) fig.colorbar(cs, ax=ax, shrink=0.9) ax.set_title("extend = %s" % extend) ax.locator_params(nbins=4) From 3525d300e008a94228964f9af98997374608e804 Mon Sep 17 00:00:00 2001 From: Gautam Sagar <47146980+gautamsagar99@users.noreply.github.com> Date: Tue, 29 Aug 2023 04:17:37 +0000 Subject: [PATCH 2/8] Added Contourf example using origin --- .../contourf_demo.py | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/galleries/examples/images_contours_and_fields/contourf_demo.py b/galleries/examples/images_contours_and_fields/contourf_demo.py index 0b204fb022b6..69b7d914f2c3 100644 --- a/galleries/examples/images_contours_and_fields/contourf_demo.py +++ b/galleries/examples/images_contours_and_fields/contourf_demo.py @@ -109,6 +109,29 @@ plt.show() +# %% +# Customizing Contour Plots with the origin Keyword +# ------------------ +# This section demonstrates how to use the origin parameter in Contour + +x = np.arange(1, 10) +y = x.reshape(-1, 1) +h = x * y + +fig, (ax1, ax2) = plt.subplots(ncols=2) +# Note: lower and upper are the values provided +# to origin argument in contourf. +for (ax, origin) in [(ax1, 'upper'), (ax2, 'lower')]: + ax.set_title(f"origin={origin}") + cs = ax.contourf(h, levels=[10, 30, 50], + colors=['#808080', '#A0A0A0', '#C0C0C0'], + extend='both', origin=origin) + cs.cmap.set_over('red') + cs.cmap.set_under('blue') + cs.changed() + +plt.show() + # %% # # .. admonition:: References From cd74288e2a72c03ccf9cd8e84d7a405dc690e1f5 Mon Sep 17 00:00:00 2001 From: Gautam Sagar <47146980+gautamsagar99@users.noreply.github.com> Date: Tue, 29 Aug 2023 15:37:11 +0000 Subject: [PATCH 3/8] Build the documentation for Contourf_demo.py --- galleries/examples/images_contours_and_fields/contourf_demo.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/galleries/examples/images_contours_and_fields/contourf_demo.py b/galleries/examples/images_contours_and_fields/contourf_demo.py index 69b7d914f2c3..1f581fd68117 100644 --- a/galleries/examples/images_contours_and_fields/contourf_demo.py +++ b/galleries/examples/images_contours_and_fields/contourf_demo.py @@ -8,7 +8,6 @@ import matplotlib.pyplot as plt import numpy as np - delta = 0.025 x = y = np.arange(-3.0, 3.01, delta) @@ -119,7 +118,7 @@ h = x * y fig, (ax1, ax2) = plt.subplots(ncols=2) -# Note: lower and upper are the values provided +# Note: lower and upper are the values provided # to origin argument in contourf. for (ax, origin) in [(ax1, 'upper'), (ax2, 'lower')]: ax.set_title(f"origin={origin}") From 6bd68f5c003a8cf226a8237111bbf65d1baf4044 Mon Sep 17 00:00:00 2001 From: Gautam Sagar <47146980+gautamsagar99@users.noreply.github.com> Date: Wed, 30 Aug 2023 01:26:31 +0000 Subject: [PATCH 4/8] Modified Documentation for Contourf_demo.py --- .../contourf_demo.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/galleries/examples/images_contours_and_fields/contourf_demo.py b/galleries/examples/images_contours_and_fields/contourf_demo.py index 1f581fd68117..5ff1fde9cc04 100644 --- a/galleries/examples/images_contours_and_fields/contourf_demo.py +++ b/galleries/examples/images_contours_and_fields/contourf_demo.py @@ -66,19 +66,14 @@ fig2, ax2 = plt.subplots(layout='constrained') levels = [-1.5, -1, -0.5, 0, 0.5, 1] -CS3 = ax2.contourf(X, Y, Z, levels, - colors=('r', 'g', 'b'), - extend='both') +CS3 = ax2.contourf(X, Y, Z, levels, colors=('r', 'g', 'b'), extend='both') # Our data range extends outside the range of levels; make # data below the lowest contour level yellow, and above the # highest level cyan: CS3.cmap.set_under('yellow') CS3.cmap.set_over('cyan') -CS4 = ax2.contour(X, Y, Z, levels, - colors=('k',), - linewidths=(3,) - ) +CS4 = ax2.contour(X, Y, Z, levels, colors=('k',), linewidths=(3,)) ax2.set_title('Listed colors (3 masked regions)') ax2.clabel(CS4, fmt='%2.1f', colors='w', fontsize=14) @@ -110,8 +105,9 @@ # %% # Customizing Contour Plots with the origin Keyword -# ------------------ -# This section demonstrates how to use the origin parameter in Contour +# ------------------------------------------------- +# This code showcases contour plot customization using the origin keyword, +# demonstrating distinct upper and lower origin perspectives. x = np.arange(1, 10) y = x.reshape(-1, 1) @@ -122,9 +118,8 @@ # to origin argument in contourf. for (ax, origin) in [(ax1, 'upper'), (ax2, 'lower')]: ax.set_title(f"origin={origin}") - cs = ax.contourf(h, levels=[10, 30, 50], - colors=['#808080', '#A0A0A0', '#C0C0C0'], - extend='both', origin=origin) + cs = ax.contourf(h, levels=[10, 30, 50], colors=[ + '#808080', '#A0A0A0', '#C0C0C0'], extend='both', origin=origin) cs.cmap.set_over('red') cs.cmap.set_under('blue') cs.changed() From cf7afd7b0010b6325a699ef6ade85e31a85e56fd Mon Sep 17 00:00:00 2001 From: Gautam Sagar <47146980+gautamsagar99@users.noreply.github.com> Date: Wed, 30 Aug 2023 13:07:34 +0000 Subject: [PATCH 5/8] Optimized the documentation for Contourf_demo.py --- .../images_contours_and_fields/contourf_demo.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/galleries/examples/images_contours_and_fields/contourf_demo.py b/galleries/examples/images_contours_and_fields/contourf_demo.py index 5ff1fde9cc04..1aad8903de10 100644 --- a/galleries/examples/images_contours_and_fields/contourf_demo.py +++ b/galleries/examples/images_contours_and_fields/contourf_demo.py @@ -114,15 +114,10 @@ h = x * y fig, (ax1, ax2) = plt.subplots(ncols=2) -# Note: lower and upper are the values provided -# to origin argument in contourf. -for (ax, origin) in [(ax1, 'upper'), (ax2, 'lower')]: - ax.set_title(f"origin={origin}") - cs = ax.contourf(h, levels=[10, 30, 50], colors=[ - '#808080', '#A0A0A0', '#C0C0C0'], extend='both', origin=origin) - cs.cmap.set_over('red') - cs.cmap.set_under('blue') - cs.changed() +ax1.set_title("origin='upper'") +ax2.set_title("origin='lower'") +ax1.contourf(h, levels=np.arange(5, 70, 5), extend='both', origin="upper") +ax2.contourf(h, levels=np.arange(5, 70, 5), extend='both', origin="lower") plt.show() From 0e1a58722b103ac5344ebff04b6f2e9566c0282b Mon Sep 17 00:00:00 2001 From: Gautam Sagar <47146980+gautamsagar99@users.noreply.github.com> Date: Wed, 30 Aug 2023 15:06:28 +0000 Subject: [PATCH 6/8] Modified documentation for Contourf_demo.py --- galleries/examples/images_contours_and_fields/contourf_demo.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/galleries/examples/images_contours_and_fields/contourf_demo.py b/galleries/examples/images_contours_and_fields/contourf_demo.py index 1aad8903de10..c0c46e9e50ec 100644 --- a/galleries/examples/images_contours_and_fields/contourf_demo.py +++ b/galleries/examples/images_contours_and_fields/contourf_demo.py @@ -106,8 +106,7 @@ # %% # Customizing Contour Plots with the origin Keyword # ------------------------------------------------- -# This code showcases contour plot customization using the origin keyword, -# demonstrating distinct upper and lower origin perspectives. +# This section demonstrates how to use the origin parameter in Contour x = np.arange(1, 10) y = x.reshape(-1, 1) From 9deecdd832186cebfc9e368e48ba3a5da48ff50e Mon Sep 17 00:00:00 2001 From: Gautam Sagar <47146980+gautamsagar99@users.noreply.github.com> Date: Wed, 30 Aug 2023 22:12:44 +0000 Subject: [PATCH 7/8] Enhanced documentation for Contourf_demo.py --- .../examples/images_contours_and_fields/contourf_demo.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/galleries/examples/images_contours_and_fields/contourf_demo.py b/galleries/examples/images_contours_and_fields/contourf_demo.py index c0c46e9e50ec..e162f343ca4d 100644 --- a/galleries/examples/images_contours_and_fields/contourf_demo.py +++ b/galleries/examples/images_contours_and_fields/contourf_demo.py @@ -104,15 +104,16 @@ plt.show() # %% -# Customizing Contour Plots with the origin Keyword -# ------------------------------------------------- -# This section demonstrates how to use the origin parameter in Contour +# Orient contour plots using the origin keyword +# ----------------------------------------------- +# This code demonstrates orienting contour plot data using the "origin" keyword x = np.arange(1, 10) y = x.reshape(-1, 1) h = x * y fig, (ax1, ax2) = plt.subplots(ncols=2) + ax1.set_title("origin='upper'") ax2.set_title("origin='lower'") ax1.contourf(h, levels=np.arange(5, 70, 5), extend='both', origin="upper") From 4185323b2372ae0b6d87465c1bd0abc2e1c71c1f Mon Sep 17 00:00:00 2001 From: Gautam Sagar <47146980+gautamsagar99@users.noreply.github.com> Date: Thu, 31 Aug 2023 03:42:29 +0000 Subject: [PATCH 8/8] Final Enhancement in documentation for Contourf_demo.py --- galleries/examples/images_contours_and_fields/contourf_demo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/galleries/examples/images_contours_and_fields/contourf_demo.py b/galleries/examples/images_contours_and_fields/contourf_demo.py index e162f343ca4d..776d2535a872 100644 --- a/galleries/examples/images_contours_and_fields/contourf_demo.py +++ b/galleries/examples/images_contours_and_fields/contourf_demo.py @@ -105,7 +105,7 @@ # %% # Orient contour plots using the origin keyword -# ----------------------------------------------- +# --------------------------------------------- # This code demonstrates orienting contour plot data using the "origin" keyword x = np.arange(1, 10)