From bda0b30f012c25fa108f949a073d6492b941bde4 Mon Sep 17 00:00:00 2001 From: Nivedita Chaudhari <76914526+niviPy@users.noreply.github.com> Date: Thu, 12 Oct 2023 20:56:26 +0000 Subject: [PATCH 1/2] Issue 26990 Fix added for image not getting rendered properly. Solution: Split image into two rows for two blocks of code resp. --- galleries/examples/misc/histogram_path.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/galleries/examples/misc/histogram_path.py b/galleries/examples/misc/histogram_path.py index 55260f9699bb..3e30dcfa424d 100644 --- a/galleries/examples/misc/histogram_path.py +++ b/galleries/examples/misc/histogram_path.py @@ -20,7 +20,7 @@ import matplotlib.patches as patches import matplotlib.path as path -fig, axs = plt.subplots(2) +fig, axs = plt.subplots(1) np.random.seed(19680801) # Fixing random state for reproducibility @@ -44,14 +44,16 @@ # make a patch out of it, don't add a margin at y=0 patch = patches.PathPatch(barpath) patch.sticky_edges.y[:] = [0] -axs[0].add_patch(patch) -axs[0].autoscale_view() +axs.add_patch(patch) +axs.autoscale_view() +plt.show() # %% # Instead of creating a three-dimensional array and using # `~.path.Path.make_compound_path_from_polys`, we could as well create the # compound path directly using vertices and codes as shown below +fig, axs = plt.subplots(1) nrects = len(left) nverts = nrects*(1+3+1) verts = np.zeros((nverts, 2)) @@ -72,9 +74,8 @@ # make a patch out of it, don't add a margin at y=0 patch = patches.PathPatch(barpath) patch.sticky_edges.y[:] = [0] -axs[1].add_patch(patch) -axs[1].autoscale_view() - +axs.add_patch(patch) +axs.autoscale_view() plt.show() # %% From 6b9615157c5447d10924f22cfa75c91f20961bf5 Mon Sep 17 00:00:00 2001 From: Nivedita Chaudhari <76914526+niviPy@users.noreply.github.com> Date: Fri, 13 Oct 2023 10:32:40 +0000 Subject: [PATCH 2/2] Updated with comments suggestions. --- galleries/examples/misc/histogram_path.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/galleries/examples/misc/histogram_path.py b/galleries/examples/misc/histogram_path.py index 3e30dcfa424d..d35e291aa8ce 100644 --- a/galleries/examples/misc/histogram_path.py +++ b/galleries/examples/misc/histogram_path.py @@ -20,8 +20,6 @@ import matplotlib.patches as patches import matplotlib.path as path -fig, axs = plt.subplots(1) - np.random.seed(19680801) # Fixing random state for reproducibility # histogram our data with numpy @@ -44,8 +42,10 @@ # make a patch out of it, don't add a margin at y=0 patch = patches.PathPatch(barpath) patch.sticky_edges.y[:] = [0] -axs.add_patch(patch) -axs.autoscale_view() + +fig, ax = plt.subplots() +ax.add_patch(patch) +ax.autoscale_view() plt.show() # %% @@ -53,7 +53,6 @@ # `~.path.Path.make_compound_path_from_polys`, we could as well create the # compound path directly using vertices and codes as shown below -fig, axs = plt.subplots(1) nrects = len(left) nverts = nrects*(1+3+1) verts = np.zeros((nverts, 2)) @@ -74,8 +73,10 @@ # make a patch out of it, don't add a margin at y=0 patch = patches.PathPatch(barpath) patch.sticky_edges.y[:] = [0] -axs.add_patch(patch) -axs.autoscale_view() + +fig, ax = plt.subplots() +ax.add_patch(patch) +ax.autoscale_view() plt.show() # %%