Skip to content

Commit

Permalink
Set figsize to consistent 8 by 8 inches, and dpi to 100
Browse files Browse the repository at this point in the history
This reduces some plot resolutions to make them a bit smaller. 100
dpi is the matplotlib default.
  • Loading branch information
jfrost-mo committed Aug 20, 2024
1 parent 0578c9b commit cd1cc75
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/CSET/operators/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand All @@ -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)

Expand All @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit cd1cc75

Please sign in to comment.