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 12, 2024
1 parent a661969 commit 20a014d
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 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")
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")
logging.info("Saved contour postage stamp plot to %s", filename)
plt.close(fig)

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

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

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

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

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

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

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

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

0 comments on commit 20a014d

Please sign in to comment.