From cd1cc7574a8a80c758b91bd3fd86e68264f07082 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 | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/CSET/operators/plot.py b/src/CSET/operators/plot.py index 5dab21462..d061fcf9d 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", dpi=100) 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", dpi=100) logging.info("Saved contour postage stamp plot to %s", filename) plt.close(fig) @@ -347,7 +347,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", dpi=100) logging.info("Saved line plot to %s", filename) plt.close(fig) @@ -436,7 +436,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", dpi=100) logging.info("Saved line plot to %s", filename) plt.close(fig) @@ -492,7 +492,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", dpi=100) logging.info("Saved scatter plot to %s", filename) plt.close(fig) @@ -551,7 +551,7 @@ def _plot_and_save_histogram_series( ) # Save plot. - fig.savefig(filename, bbox_inches="tight", dpi=150) + fig.savefig(filename, bbox_inches="tight", dpi=100) logging.info("Saved line plot to %s", filename) plt.close(fig) @@ -600,7 +600,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 @@ -620,7 +620,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", dpi=100) logging.info("Saved histogram postage stamp plot to %s", filename) plt.close(fig) @@ -635,7 +635,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) @@ -658,7 +658,7 @@ def _plot_and_save_postage_stamps_in_single_plot_histogram_series( ax.legend() # Save the figure to a file - plt.savefig(filename) + plt.savefig(filename, bbox_inches="tight", dpi=100) # Close the figure plt.close(fig)