From 20a014d78e60a7df4840092f79c15b14efd67927 Mon Sep 17 00:00:00 2001 From: James Frost Date: Fri, 9 Aug 2024 16:21:51 +0100 Subject: [PATCH] Set figsize to consistent 8 by 8 inches, and dpi to 100 This reduces some plot resolutions to make them a bit smaller. 100 dpi is the matplotlib default. --- src/CSET/operators/plot.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/CSET/operators/plot.py b/src/CSET/operators/plot.py index 17cfe55f8..864d6c91f 100644 --- a/src/CSET/operators/plot.py +++ b/src/CSET/operators/plot.py @@ -200,7 +200,7 @@ def _plot_and_save_contour_plot( """ # Setup plot details, size, resolution, etc. - fig = plt.figure(figsize=(15, 15), facecolor="w", edgecolor="k") + fig = plt.figure(figsize=(8, 8), facecolor="w", edgecolor="k") # Specify the color bar cmap, levels, norm = _colorbar_map_levels(cube.name()) @@ -248,7 +248,7 @@ def _plot_and_save_contour_plot( cbar.set_label(label=f"{cube.name()} ({cube.units})", size=20) # Save plot. - fig.savefig(filename, bbox_inches="tight", dpi=150) + fig.savefig(filename, bbox_inches="tight") logging.info("Saved contour plot to %s", filename) plt.close(fig) @@ -279,7 +279,7 @@ def _plot_and_save_postage_stamp_contour_plot( # Use the smallest square grid that will fit the members. grid_size = int(math.ceil(math.sqrt(len(cube.coord(stamp_coordinate).points)))) - fig = plt.figure(figsize=(10, 10)) + fig = plt.figure(figsize=(8, 8)) # Specify the color bar cmap, levels, norm = _colorbar_map_levels(cube.name()) @@ -311,7 +311,7 @@ def _plot_and_save_postage_stamp_contour_plot( # Overall figure title. fig.suptitle(title) - fig.savefig(filename, bbox_inches="tight", dpi=150) + fig.savefig(filename, bbox_inches="tight") logging.info("Saved contour postage stamp plot to %s", filename) plt.close(fig) @@ -335,7 +335,7 @@ def _plot_and_save_pcolormesh_plot( """ # Setup plot details, size, resolution, etc. - fig = plt.figure(figsize=(15, 15), facecolor="w", edgecolor="k") + fig = plt.figure(figsize=(8, 8), facecolor="w", edgecolor="k") # Specify the color bar cmap, levels, norm = _colorbar_map_levels(cube.name()) @@ -383,7 +383,7 @@ def _plot_and_save_pcolormesh_plot( cbar.set_label(label=f"{cube.name()} ({cube.units})", size=20) # Save plot. - fig.savefig(filename, bbox_inches="tight", dpi=150) + fig.savefig(filename, bbox_inches="tight") logging.info("Saved contour plot to %s", filename) plt.close(fig) @@ -414,7 +414,7 @@ def _plot_and_save_postage_stamp_pcolormesh_plot( # Use the smallest square grid that will fit the members. grid_size = int(math.ceil(math.sqrt(len(cube.coord(stamp_coordinate).points)))) - fig = plt.figure(figsize=(10, 10)) + fig = plt.figure(figsize=(8, 8)) # Specify the color bar cmap, levels, norm = _colorbar_map_levels(cube.name()) @@ -446,7 +446,7 @@ def _plot_and_save_postage_stamp_pcolormesh_plot( # Overall figure title. fig.suptitle(title) - fig.savefig(filename, bbox_inches="tight", dpi=150) + fig.savefig(filename, bbox_inches="tight") logging.info("Saved contour postage stamp plot to %s", filename) plt.close(fig) @@ -482,7 +482,7 @@ def _plot_and_save_line_series( ax.autoscale() # Save plot. - fig.savefig(filename, bbox_inches="tight", dpi=150) + fig.savefig(filename, bbox_inches="tight") logging.info("Saved line plot to %s", filename) plt.close(fig) @@ -571,7 +571,7 @@ def _plot_and_save_vertical_line_series( ax.autoscale() # Save plot. - fig.savefig(filename, bbox_inches="tight", dpi=150) + fig.savefig(filename, bbox_inches="tight") logging.info("Saved line plot to %s", filename) plt.close(fig) @@ -627,7 +627,7 @@ def _plot_and_save_scatter_plot( ax.autoscale() # Save plot. - fig.savefig(filename, bbox_inches="tight", dpi=150) + fig.savefig(filename, bbox_inches="tight") logging.info("Saved scatter plot to %s", filename) plt.close(fig) @@ -686,7 +686,7 @@ def _plot_and_save_histogram_series( ) # Save plot. - fig.savefig(filename, bbox_inches="tight", dpi=150) + fig.savefig(filename, bbox_inches="tight") logging.info("Saved line plot to %s", filename) plt.close(fig) @@ -735,7 +735,7 @@ def _plot_and_save_postage_stamp_histogram_series( # Use the smallest square grid that will fit the members. grid_size = int(math.ceil(math.sqrt(len(cube.coord(stamp_coordinate).points)))) - fig = plt.figure(figsize=(10, 10), facecolor="w", edgecolor="k") + fig = plt.figure(figsize=(8, 8), facecolor="w", edgecolor="k") # Make a subplot for each member. for member, subplot in zip( cube.slices_over(stamp_coordinate), range(1, grid_size**2 + 1), strict=False @@ -755,7 +755,7 @@ def _plot_and_save_postage_stamp_histogram_series( # Overall figure title. fig.suptitle(title) - fig.savefig(filename, bbox_inches="tight", dpi=150) + fig.savefig(filename, bbox_inches="tight") logging.info("Saved histogram postage stamp plot to %s", filename) plt.close(fig) @@ -770,7 +770,7 @@ def _plot_and_save_postage_stamps_in_single_plot_histogram_series( histtype: str = "step", **kwargs, ): - fig, ax = plt.subplots(figsize=(10, 10), facecolor="w", edgecolor="k") + fig, ax = plt.subplots(figsize=(8, 8), facecolor="w", edgecolor="k") ax.set_title(title) ax.set_xlim(vmin, vmax) ax.set_ylim(0, 1)