From 256d6ff1ebfa9bb51e3f62b8c33090443873e4cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Le=20Guyader?= <loic.le.guyader@xfel.eu> Date: Mon, 5 Sep 2022 10:22:29 +0200 Subject: [PATCH] Removes all tight_layout calls --- doc/changelog.rst | 1 + doc/index.rst | 15 +++++++++++++++ src/toolbox_scs/detectors/digitizers.py | 1 - src/toolbox_scs/misc/bunch_pattern.py | 1 - src/toolbox_scs/misc/laser_utils.py | 2 +- src/toolbox_scs/routines/XAS.py | 1 - src/toolbox_scs/routines/knife_edge.py | 1 - 7 files changed, 17 insertions(+), 5 deletions(-) diff --git a/doc/changelog.rst b/doc/changelog.rst index c7d7dc9..5439780 100644 --- a/doc/changelog.rst +++ b/doc/changelog.rst @@ -9,6 +9,7 @@ unreleased - **Improvements** + - remove calls to matplotlib tight_layout :mr:`206` - **New Features** diff --git a/doc/index.rst b/doc/index.rst index a260921..27730a8 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -19,6 +19,21 @@ where in this example 2780 is the proposal number. After this and refreshing the browser, a new kernel named ``SCS Toolbox (p002780)`` is available and should be used to run jupyter notebooks on the Maxwell Jupyter hub. +Figures setup: enabling matplotlib constrained layout ++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +To get the best looking figures generated by the SCS Toolbox, you +need to enable the experimental constrained_layout_ solver in matplotlib. This +is done in jupyter notebook with adding at the start the following lines: + +.. code:: python + + import matplotlib.pyplot as plt + plt.rcParams['figure.constrained_layout.use'] = True + +.. _constrained_layout: https://matplotlib.org/stable/tutorials/intermediate/constrainedlayout_guide.html + + Alternative: Manual ToolBox Installation ++++++++++++++++++++++++++++++++++++++++ diff --git a/src/toolbox_scs/detectors/digitizers.py b/src/toolbox_scs/detectors/digitizers.py index 3dadcb9..297a774 100644 --- a/src/toolbox_scs/detectors/digitizers.py +++ b/src/toolbox_scs/detectors/digitizers.py @@ -1102,7 +1102,6 @@ def calibrateTIM(data, rollingWindow=200, mcp=1, plot=False, use_apd=True, intst ax.set_ylabel(label_trace, size=10) ax.set_xlabel('sample #', size=10) ax.legend(fontsize=8) - plt.tight_layout() return F diff --git a/src/toolbox_scs/misc/bunch_pattern.py b/src/toolbox_scs/misc/bunch_pattern.py index 852f9ed..90deb34 100644 --- a/src/toolbox_scs/misc/bunch_pattern.py +++ b/src/toolbox_scs/misc/bunch_pattern.py @@ -171,7 +171,6 @@ def pulsePatternInfo(data, plot=False): plt.plot(data['npulses_sase1'].trainId, data['npulses_sase1'], '^-', ms=3, color='C2', label='SASE 1') plt.legend() - plt.tight_layout() def repRate(data=None, runNB=None, proposalNB=None, key='sase3'): diff --git a/src/toolbox_scs/misc/laser_utils.py b/src/toolbox_scs/misc/laser_utils.py index 99698e1..0f05296 100644 --- a/src/toolbox_scs/misc/laser_utils.py +++ b/src/toolbox_scs/misc/laser_utils.py @@ -110,5 +110,5 @@ def fluenceCalibration(hwp, power_mW, npulses, w0x, w0y=None, return 1e7*x*np.pi*w0x*w0y/2 ax2 = ax.secondary_yaxis('right', functions=(fTe, eTf)) ax2.set_ylabel(r'Pulse energy [$\mu$J]') - fig.tight_layout() + return F*1e-1, fit_F, E*1e6, fit_E diff --git a/src/toolbox_scs/routines/XAS.py b/src/toolbox_scs/routines/XAS.py index 878cc28..0f483c5 100644 --- a/src/toolbox_scs/routines/XAS.py +++ b/src/toolbox_scs/routines/XAS.py @@ -235,7 +235,6 @@ def xas(nrun, bins=None, Iokey='SCS_SA3', Itkey='MCP3peaks', nrjkey='nrj', color='C0', alpha=0.2) ax2.set_xlabel('Energy (eV)') ax2.set_ylabel('counts') - plt.tight_layout() return {'nrj': bins_c, 'muA': muA, 'sterrA': sterrA, 'sigmaA': nosample['sigmaA'], 'muIo': nosample['muIo'], diff --git a/src/toolbox_scs/routines/knife_edge.py b/src/toolbox_scs/routines/knife_edge.py index 78ad7d5..5f1e47e 100644 --- a/src/toolbox_scs/routines/knife_edge.py +++ b/src/toolbox_scs/routines/knife_edge.py @@ -93,4 +93,3 @@ def plot_knife_edge(positions, intensities, fit_params, rel_err, title, plt.ylabel(signalKey) plt.xlabel(axisKey + ' position [mm]') plt.title(title) - plt.tight_layout() -- GitLab