Skip to content

Commit d75c573

Browse files
authored
Merge pull request #240 from Jammy2211/feature/plot-improvements-2
Plot improvements batch 2
2 parents c196760 + 93a325b commit d75c573

File tree

10 files changed

+76
-48
lines changed

10 files changed

+76
-48
lines changed

autoarray/config/visualize/general.yaml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,23 @@ colorbar:
2727
pad: 0.01 # Padding between colorbar and axes.
2828
labelrotation: 90 # Rotation of colorbar tick labels in degrees.
2929
labelsize: 22 # Font size of colorbar tick labels for single-panel figures.
30-
labelsize_subplot: 22 # Font size of colorbar tick labels for subplot panels.
30+
labelsize_subplot: 33 # Font size of colorbar tick labels for subplot panels.
3131
mat_plot:
3232
figure:
3333
figsize: (7, 7) # Default figure size. Override via aplt.Figure(figsize=(...)).
34+
subplot_shape_to_figsize_factor: (6, 6) # Per-panel size factor for subplots. figsize = (cols*fx, rows*fy).
35+
title:
36+
fontsize: 24 # Default title font size for single-panel figures.
37+
title_subplot:
38+
fontsize: 20 # Default title font size for subplot panels.
3439
yticks:
3540
fontsize: 22 # Default y-tick font size. Override via aplt.YTicks(fontsize=...).
3641
yticks_subplot:
37-
fontsize: 18 # Default y-tick font size for subplot panels.
42+
fontsize: 22 # Default y-tick font size for subplot panels.
3843
xticks:
3944
fontsize: 22 # Default x-tick font size. Override via aplt.XTicks(fontsize=...).
4045
xticks_subplot:
41-
fontsize: 18 # Default x-tick font size for subplot panels.
42-
title:
43-
fontsize: 24 # Default title font size. Override via aplt.Title(fontsize=...).
46+
fontsize: 22 # Default x-tick font size for subplot panels.
4447
ylabel:
4548
fontsize: 16 # Default y-label font size. Override via aplt.YLabel(fontsize=...).
4649
xlabel:

autoarray/dataset/plot/imaging_plots.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
import matplotlib.pyplot as plt
44

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

77

88
def subplot_imaging_dataset(
99
dataset,
1010
output_path: Optional[str] = None,
11-
output_filename: str = "subplot_dataset",
11+
output_filename: str = "dataset",
1212
output_format: str = "png",
1313
colormap=None,
1414
use_log10: bool = False,
@@ -51,7 +51,7 @@ def subplot_imaging_dataset(
5151

5252
from autoarray.plot.array import plot_array
5353

54-
fig, axes = plt.subplots(3, 3, figsize=(21, 21))
54+
fig, axes = plt.subplots(3, 3, figsize=conf_subplot_figsize(3, 3))
5555
axes = axes.flatten()
5656

5757
plot_array(
@@ -147,7 +147,7 @@ def subplot_imaging_dataset(
147147
def subplot_imaging_dataset_list(
148148
dataset_list,
149149
output_path=None,
150-
output_filename: str = "subplot_dataset_combined",
150+
output_filename: str = "dataset_combined",
151151
output_format="png",
152152
):
153153
"""
@@ -172,7 +172,7 @@ def subplot_imaging_dataset_list(
172172
from autoarray.plot.array import plot_array
173173

174174
n = len(dataset_list)
175-
fig, axes = plt.subplots(n, 3, figsize=(21, 7 * n))
175+
fig, axes = plt.subplots(n, 3, figsize=conf_subplot_figsize(n, 3))
176176
if n == 1:
177177
axes = [axes]
178178
for i, dataset in enumerate(dataset_list):

autoarray/dataset/plot/interferometer_plots.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
from autoarray.plot.array import plot_array
77
from autoarray.plot.grid import plot_grid
88
from autoarray.plot.yx import plot_yx
9-
from autoarray.plot.utils import subplot_save, hide_unused_axes
9+
from autoarray.plot.utils import subplot_save, hide_unused_axes, conf_subplot_figsize
1010
from autoarray.structures.grids.irregular_2d import Grid2DIrregular
1111

1212

1313
def subplot_interferometer_dataset(
1414
dataset,
1515
output_path: Optional[str] = None,
16-
output_filename: str = "subplot_dataset",
16+
output_filename: str = "dataset",
1717
output_format: str = "png",
1818
colormap=None,
1919
use_log10: bool = False,
@@ -39,7 +39,7 @@ def subplot_interferometer_dataset(
3939
use_log10
4040
Apply log10 normalisation to image panels.
4141
"""
42-
fig, axes = plt.subplots(2, 3, figsize=(21, 14))
42+
fig, axes = plt.subplots(2, 3, figsize=conf_subplot_figsize(2, 3))
4343
axes = axes.flatten()
4444

4545
plot_grid(dataset.data.in_grid, ax=axes[0], title="Visibilities")
@@ -92,7 +92,7 @@ def subplot_interferometer_dataset(
9292
def subplot_interferometer_dirty_images(
9393
dataset,
9494
output_path: Optional[str] = None,
95-
output_filename: str = "subplot_dirty_images",
95+
output_filename: str = "dirty_images",
9696
output_format: str = "png",
9797
colormap=None,
9898
use_log10: bool = False,
@@ -115,7 +115,7 @@ def subplot_interferometer_dirty_images(
115115
use_log10
116116
Apply log10 normalisation.
117117
"""
118-
fig, axes = plt.subplots(1, 3, figsize=(21, 7))
118+
fig, axes = plt.subplots(1, 3, figsize=conf_subplot_figsize(1, 3))
119119

120120
plot_array(
121121
dataset.dirty_image,

autoarray/fit/plot/fit_imaging_plots.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
import matplotlib.pyplot as plt
44

55
from autoarray.plot.array import plot_array
6-
from autoarray.plot.utils import subplot_save, symmetric_vmin_vmax, hide_unused_axes
6+
from autoarray.plot.utils import subplot_save, symmetric_vmin_vmax, hide_unused_axes, conf_subplot_figsize
77

88

99
def subplot_fit_imaging(
1010
fit,
1111
output_path: Optional[str] = None,
12-
output_filename: str = "subplot_fit",
12+
output_filename: str = "fit",
1313
output_format: str = "png",
1414
colormap=None,
1515
use_log10: bool = False,
@@ -43,7 +43,7 @@ def subplot_fit_imaging(
4343
grid, positions, lines
4444
Optional overlays forwarded to every panel.
4545
"""
46-
fig, axes = plt.subplots(2, 3, figsize=(21, 14))
46+
fig, axes = plt.subplots(2, 3, figsize=conf_subplot_figsize(2, 3))
4747
axes = axes.flatten()
4848

4949
plot_array(
@@ -103,6 +103,7 @@ def subplot_fit_imaging(
103103
use_log10=False,
104104
vmin=vmin_n,
105105
vmax=vmax_n,
106+
cb_unit=r"$\sigma$",
106107
grid=grid,
107108
positions=positions,
108109
lines=lines,
@@ -113,6 +114,7 @@ def subplot_fit_imaging(
113114
title="Chi-Squared Map",
114115
colormap=colormap,
115116
use_log10=use_log10,
117+
cb_unit=r"$\chi^2$",
116118
grid=grid,
117119
positions=positions,
118120
lines=lines,

autoarray/fit/plot/fit_interferometer_plots.py

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

66
from autoarray.plot.array import plot_array
77
from autoarray.plot.yx import plot_yx
8-
from autoarray.plot.utils import subplot_save, symmetric_vmin_vmax, hide_unused_axes
8+
from autoarray.plot.utils import subplot_save, symmetric_vmin_vmax, hide_unused_axes, conf_subplot_figsize
99

1010

1111
def subplot_fit_interferometer(
1212
fit,
1313
output_path: Optional[str] = None,
14-
output_filename: str = "subplot_fit",
14+
output_filename: str = "fit",
1515
output_format: str = "png",
1616
colormap=None,
1717
use_log10: bool = False,
@@ -40,7 +40,7 @@ def subplot_fit_interferometer(
4040
Not used here (UV-plane residuals are scatter plots); kept for API
4141
consistency.
4242
"""
43-
fig, axes = plt.subplots(2, 3, figsize=(21, 14))
43+
fig, axes = plt.subplots(2, 3, figsize=conf_subplot_figsize(2, 3))
4444
axes = axes.flatten()
4545

4646
uv = fit.dataset.uv_distances / 10**3.0
@@ -106,7 +106,7 @@ def subplot_fit_interferometer(
106106
def subplot_fit_interferometer_dirty_images(
107107
fit,
108108
output_path: Optional[str] = None,
109-
output_filename: str = "subplot_fit_dirty_images",
109+
output_filename: str = "fit_dirty_images",
110110
output_format: str = "png",
111111
colormap=None,
112112
use_log10: bool = False,
@@ -135,7 +135,7 @@ def subplot_fit_interferometer_dirty_images(
135135
residuals_symmetric_cmap
136136
Centre residual colour scale symmetrically around zero.
137137
"""
138-
fig, axes = plt.subplots(2, 3, figsize=(21, 14))
138+
fig, axes = plt.subplots(2, 3, figsize=conf_subplot_figsize(2, 3))
139139
axes = axes.flatten()
140140

141141
plot_array(
@@ -183,13 +183,15 @@ def subplot_fit_interferometer_dirty_images(
183183
use_log10=False,
184184
vmin=vmin_n,
185185
vmax=vmax_n,
186+
cb_unit=r"$\sigma$",
186187
)
187188
plot_array(
188189
fit.dirty_chi_squared_map,
189190
ax=axes[5],
190191
title="Dirty Chi-Squared Map",
191192
colormap=colormap,
192193
use_log10=use_log10,
194+
cb_unit=r"$\chi^2$",
193195
)
194196

195197
hide_unused_axes(axes)

autoarray/inversion/plot/inversion_plots.py

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

1010
from autoarray.inversion.mappers.abstract import Mapper
1111
from autoarray.plot.array import plot_array
12-
from autoarray.plot.utils import numpy_grid, numpy_lines, numpy_positions, subplot_save, hide_unused_axes
12+
from autoarray.plot.utils import numpy_grid, numpy_lines, numpy_positions, subplot_save, hide_unused_axes, conf_subplot_figsize
1313
from autoarray.inversion.plot.mapper_plots import plot_mapper
1414
from autoarray.structures.arrays.uniform_2d import Array2D
1515

@@ -20,7 +20,7 @@ def subplot_of_mapper(
2020
inversion,
2121
mapper_index: int = 0,
2222
output_path: Optional[str] = None,
23-
output_filename: str = "subplot_inversion",
23+
output_filename: str = "inversion",
2424
output_format: str = "png",
2525
colormap=None,
2626
use_log10: bool = False,
@@ -53,7 +53,7 @@ def subplot_of_mapper(
5353
"""
5454
mapper = inversion.cls_list_from(cls=Mapper)[mapper_index]
5555

56-
fig, axes = plt.subplots(3, 4, figsize=(28, 21))
56+
fig, axes = plt.subplots(3, 4, figsize=conf_subplot_figsize(3, 4))
5757
axes = axes.flatten()
5858

5959
# panel 0: data subtracted
@@ -226,7 +226,7 @@ def subplot_mappings(
226226
inversion,
227227
pixelization_index: int = 0,
228228
output_path: Optional[str] = None,
229-
output_filename: str = "subplot_mappings",
229+
output_filename: str = "mappings",
230230
output_format: str = "png",
231231
colormap=None,
232232
use_log10: bool = False,
@@ -273,7 +273,7 @@ def subplot_mappings(
273273
)
274274
mapper.slim_indexes_for_pix_indexes(pix_indexes=pix_indexes)
275275

276-
fig, axes = plt.subplots(2, 2, figsize=(14, 14))
276+
fig, axes = plt.subplots(2, 2, figsize=conf_subplot_figsize(2, 2))
277277
axes = axes.flatten()
278278

279279
# panel 0: data subtracted

autoarray/inversion/plot/mapper_plots.py

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

66
from autoarray.plot.array import plot_array
77
from autoarray.plot.inversion import plot_inversion_reconstruction
8-
from autoarray.plot.utils import numpy_grid, numpy_lines, subplot_save
8+
from autoarray.plot.utils import numpy_grid, numpy_lines, subplot_save, conf_subplot_figsize
99

1010
logger = logging.getLogger(__name__)
1111

@@ -77,7 +77,7 @@ def subplot_image_and_mapper(
7777
mapper,
7878
image,
7979
output_path: Optional[str] = None,
80-
output_filename: str = "subplot_image_and_mapper",
80+
output_filename: str = "image_and_mapper",
8181
output_format: str = "png",
8282
colormap=None,
8383
use_log10: bool = False,
@@ -108,7 +108,7 @@ def subplot_image_and_mapper(
108108
lines
109109
Lines to overlay on both panels.
110110
"""
111-
fig, axes = plt.subplots(1, 2, figsize=(14, 7))
111+
fig, axes = plt.subplots(1, 2, figsize=conf_subplot_figsize(1, 2))
112112

113113
plot_array(
114114
image,

autoarray/plot/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def _set_backend():
2828
apply_extent,
2929
apply_labels,
3030
conf_figsize,
31+
conf_subplot_figsize,
3132
conf_mat_plot_fontsize,
3233
save_figure,
3334
subplot_save,

autoarray/plot/array.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ def plot_array(
5959
output_path: Optional[str] = None,
6060
output_filename: str = "array",
6161
output_format: str = "png",
62-
structure=None,
6362
) -> None:
6463
"""
6564
Plot a 2D array (image) using ``plt.imshow``.
@@ -120,9 +119,8 @@ def plot_array(
120119
"""
121120
# --- autoarray extraction --------------------------------------------------
122121
array = zoom_array(array)
122+
structure = array
123123
try:
124-
if structure is None:
125-
structure = array
126124
if extent is None:
127125
extent = array.geometry.extent
128126
if mask is None:

0 commit comments

Comments
 (0)