Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion autoarray/plot/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@
logger = logging.getLogger(__name__)


_FAST_PLOTS = os.environ.get("PYAUTO_FAST_PLOTS") == "1"


def tight_layout():
"""Call ``plt.tight_layout()`` unless fast-plot mode is active.

When ``PYAUTO_FAST_PLOTS=1`` the expensive layout-optimisation pass
is skipped. All figure creation, data computation, and rendering
still execute — only the final spacing adjustment is bypassed.
"""
if os.environ.get("PYAUTO_FAST_PLOTS") == "1":
if _FAST_PLOTS:
return
plt.tight_layout()

Expand Down Expand Up @@ -338,6 +341,10 @@ def subplot_save(fig, output_path, output_filename, output_format=None):
if _output_mode_save(fig, output_filename):
return

if _FAST_PLOTS:
plt.close(fig)
return

if output_format == "show" or not output_path:
plt.show()
else:
Expand Down Expand Up @@ -508,6 +515,10 @@ def save_figure(
if _output_mode_save(fig, filename):
return

if _FAST_PLOTS:
plt.close(fig)
return

formats = format if isinstance(format, (list, tuple)) else [format]

if all(f == "show" for f in formats) or not path:
Expand Down
Loading