Skip to content

Commit 8428020

Browse files
authored
Merge pull request #422 from PyAutoLabs/feature/fast-plots-tight-layout
feat: use tight_layout wrapper for PYAUTO_FAST_PLOTS support
2 parents 3001f92 + 1fdfab3 commit 8428020

7 files changed

Lines changed: 29 additions & 29 deletions

File tree

autolens/imaging/plot/fit_imaging_plots.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from autogalaxy.plot.plot_utils import plot_array
1010
from autoarray.plot.array import _zoom_array_2d
11-
from autoarray.plot.utils import save_figure, hide_unused_axes, conf_subplot_figsize
11+
from autoarray.plot.utils import save_figure, hide_unused_axes, conf_subplot_figsize, tight_layout
1212
from autoarray.plot.utils import numpy_lines as _to_lines
1313
from autoarray.inversion.mappers.abstract import Mapper
1414
from autoarray.inversion.plot.mapper_plots import plot_mapper
@@ -320,7 +320,7 @@ def subplot_fit(
320320
vmax=source_vmax)
321321

322322
hide_unused_axes(axes_flat)
323-
plt.tight_layout()
323+
tight_layout()
324324
save_figure(fig, path=output_path, filename=f"fit{plane_index_tag}", format=output_format)
325325

326326

@@ -384,7 +384,7 @@ def subplot_fit_x1_plane(
384384
plot_array(array=norm_resid, ax=axes_flat[5], title="Normalized Residual Map",
385385
colormap=colormap, vmin=-_abs_max, vmax=_abs_max, cb_unit=r"$\sigma$")
386386

387-
plt.tight_layout()
387+
tight_layout()
388388
save_figure(fig, path=output_path, filename="fit_x1_plane", format=output_format)
389389

390390

@@ -508,7 +508,7 @@ def subplot_fit_log10(
508508
lines=source_plane_lines, line_colors=source_plane_line_colors,
509509
vmax=source_vmax)
510510

511-
plt.tight_layout()
511+
tight_layout()
512512
save_figure(fig, path=output_path, filename=f"fit_log10{plane_index_tag}", format=output_format)
513513

514514

@@ -569,7 +569,7 @@ def subplot_fit_log10_x1_plane(
569569
plot_array(array=fit.chi_squared_map, ax=axes_flat[5], title="Chi-Squared Map",
570570
colormap=colormap, use_log10=True, cb_unit=r"$\chi^2$")
571571

572-
plt.tight_layout()
572+
tight_layout()
573573
save_figure(fig, path=output_path, filename="fit_log10", format=output_format)
574574

575575

@@ -637,7 +637,7 @@ def subplot_of_planes(
637637

638638
_plot_source_plane(fit, axes_flat[3], pidx, colormap=colormap)
639639

640-
plt.tight_layout()
640+
tight_layout()
641641
save_figure(fig, path=output_path, filename=f"fit_of_plane_{pidx}", format=output_format)
642642

643643

@@ -762,7 +762,7 @@ def subplot_tracer_from_fit(
762762
plot_array(array=magnification, ax=axes_flat[8], title="Magnification",
763763
colormap=colormap)
764764

765-
plt.tight_layout()
765+
tight_layout()
766766
save_figure(fig, path=output_path, filename="tracer", format=output_format)
767767

768768

@@ -844,7 +844,7 @@ def subplot_fit_combined(
844844
plot_array(array=fit.normalized_residual_map, ax=row_axes[5],
845845
title="Normalized Residual Map", colormap=colormap, cb_unit=r"$\sigma$")
846846

847-
plt.tight_layout()
847+
tight_layout()
848848
save_figure(fig, path=output_path, filename="fit_combined", format=output_format)
849849

850850

@@ -920,7 +920,7 @@ def subplot_fit_combined_log10(
920920
plot_array(array=fit.normalized_residual_map, ax=row_axes[5],
921921
title="Normalized Residual Map", colormap=colormap, cb_unit=r"$\sigma$")
922922

923-
plt.tight_layout()
923+
tight_layout()
924924
save_figure(fig, path=output_path, filename="fit_combined_log10", format=output_format)
925925

926926

autolens/interferometer/plot/fit_interferometer_plots.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from autogalaxy.plot.plot_utils import plot_array
1010
from autoarray.plot.yx import plot_yx
11-
from autoarray.plot.utils import save_figure, conf_subplot_figsize
11+
from autoarray.plot.utils import save_figure, conf_subplot_figsize, tight_layout
1212
from autoarray.plot.utils import numpy_lines as _to_lines
1313
from autoarray.inversion.mappers.abstract import Mapper
1414
from autoarray.inversion.plot.mapper_plots import plot_mapper
@@ -264,7 +264,7 @@ def subplot_fit(
264264
lines=source_plane_lines,
265265
line_colors=source_plane_line_colors)
266266

267-
plt.tight_layout()
267+
tight_layout()
268268
save_figure(fig, path=output_path, filename="fit", format=output_format)
269269

270270

@@ -321,7 +321,7 @@ def subplot_fit_dirty_images(
321321
plot_array(array=fit.dirty_chi_squared_map, ax=axes_flat[5],
322322
title="Dirty Chi-Squared Map", colormap=colormap, cb_unit=r"$\chi^2$")
323323

324-
plt.tight_layout()
324+
tight_layout()
325325
save_figure(fig, path=output_path, filename="fit_dirty_images", format=output_format)
326326

327327

@@ -383,7 +383,7 @@ def subplot_fit_real_space(
383383
title="Source Reconstruction",
384384
lines=source_plane_lines, line_colors=source_plane_line_colors)
385385

386-
plt.tight_layout()
386+
tight_layout()
387387
save_figure(fig, path=output_path, filename="fit_real_space", format=output_format)
388388

389389

@@ -513,5 +513,5 @@ def subplot_tracer_from_fit(
513513
plot_array(array=magnification, ax=axes_flat[8], title="Magnification",
514514
colormap=colormap)
515515

516-
plt.tight_layout()
516+
tight_layout()
517517
save_figure(fig, path=output_path, filename="tracer", format=output_format)

autolens/lens/plot/sensitivity_plots.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import autoarray as aa
77

88
from autogalaxy.plot.plot_utils import plot_array
9-
from autoarray.plot.utils import save_figure
9+
from autoarray.plot.utils import save_figure, tight_layout
1010

1111

1212
def subplot_tracer_images(
@@ -111,7 +111,7 @@ def subplot_tracer_images(
111111
title="Residual Map (Subhalo - No Subhalo)",
112112
colormap=colormap, use_log10=use_log10, lines=no_perturb_cc_lines)
113113

114-
plt.tight_layout()
114+
tight_layout()
115115
save_figure(fig, path=output_path, filename="lensed_images", format=output_format)
116116

117117

@@ -240,7 +240,7 @@ def subplot_sensitivity(
240240
except (TypeError, AttributeError):
241241
pass
242242

243-
plt.tight_layout()
243+
tight_layout()
244244
save_figure(fig, path=output_path, filename="sensitivity", format=output_format)
245245

246246

@@ -288,5 +288,5 @@ def subplot_figures_of_merit_grid(
288288
fig, ax = plt.subplots(1, 1, figsize=(7, 7))
289289
plot_array(array=figures_of_merit, ax=ax, title="Increase in Log Evidence",
290290
colormap=colormap)
291-
plt.tight_layout()
291+
tight_layout()
292292
save_figure(fig, path=output_path, filename="sensitivity", format=output_format)

autolens/lens/plot/subhalo_plots.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from typing import Optional
44

55
from autogalaxy.plot.plot_utils import plot_array
6-
from autoarray.plot.utils import save_figure
6+
from autoarray.plot.utils import save_figure, tight_layout
77
from autolens.imaging.plot.fit_imaging_plots import _plot_source_plane
88

99

@@ -94,7 +94,7 @@ def subplot_detection_imaging(
9494
colormap=colormap,
9595
)
9696

97-
plt.tight_layout()
97+
tight_layout()
9898
save_figure(fig, path=output_path, filename="detection_imaging", format=output_format)
9999

100100

@@ -173,5 +173,5 @@ def subplot_detection_fits(
173173
_plot_source_plane(fit_imaging_with_subhalo, axes[1][2], plane_index=1,
174174
colormap=colormap)
175175

176-
plt.tight_layout()
176+
tight_layout()
177177
save_figure(fig, path=output_path, filename="detection_fits", format=output_format)

autolens/lens/plot/tracer_plots.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import autogalaxy as ag
77

88
from autogalaxy.plot.plot_utils import plot_array
9-
from autoarray.plot.utils import save_figure, hide_unused_axes, conf_subplot_figsize
9+
from autoarray.plot.utils import save_figure, hide_unused_axes, conf_subplot_figsize, tight_layout
1010
from autoarray.plot.utils import numpy_positions as _to_positions
1111

1212

@@ -187,7 +187,7 @@ def subplot_tracer(
187187
lines=image_plane_lines, line_colors=image_plane_line_colors, colormap=colormap)
188188

189189
hide_unused_axes(axes_flat)
190-
plt.tight_layout()
190+
tight_layout()
191191
save_figure(fig, path=output_path, filename="tracer", format=output_format)
192192

193193

@@ -241,7 +241,7 @@ def subplot_lensed_images(
241241
use_log10=use_log10,
242242
)
243243

244-
plt.tight_layout()
244+
tight_layout()
245245
save_figure(fig, path=output_path, filename="lensed_images", format=output_format)
246246

247247

@@ -328,7 +328,7 @@ def subplot_galaxies_images(
328328
)
329329
idx += 1
330330

331-
plt.tight_layout()
331+
tight_layout()
332332
save_figure(fig, path=output_path, filename="galaxies_images", format=output_format)
333333

334334

autolens/point/plot/fit_point_plots.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import numpy as np
33
from typing import Optional
44

5-
from autoarray.plot.utils import save_figure, conf_subplot_figsize
5+
from autoarray.plot.utils import save_figure, conf_subplot_figsize, tight_layout
66

77

88
def subplot_fit(
@@ -81,5 +81,5 @@ def subplot_fit(
8181
output_format=output_format,
8282
)
8383

84-
plt.tight_layout()
84+
tight_layout()
8585
save_figure(fig, path=output_path, filename="fit", format=output_format)

autolens/point/plot/point_dataset_plots.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import numpy as np
33
from typing import Optional
44

5-
from autoarray.plot.utils import save_figure, conf_subplot_figsize
5+
from autoarray.plot.utils import save_figure, conf_subplot_figsize, tight_layout
66

77

88
def subplot_dataset(
@@ -69,5 +69,5 @@ def subplot_dataset(
6969
output_format=output_format,
7070
)
7171

72-
plt.tight_layout()
72+
tight_layout()
7373
save_figure(fig, path=output_path, filename="dataset_point", format=output_format)

0 commit comments

Comments
 (0)