Consecutive mslice script figures bug

Hello,

when running the attached two script one after the other to plot 2D and 1D plot, the 1D plot is corrupted. This does not happen if they are run separately.
Tatiana

2D plot script

Python Script Generated by Mslice on 2019-04-02 11:00:21

import mslice.cli as mc
import mslice.plotting.pyplot as plt

DytBuOCl_Ei90_00meV_5K = mc.Load(Filename=’/home/ecz46986/RB1910185/SPE/Dy(tBuO)Cl_Ei90.00meV_5K.nxspe’, OutputWorkspace=‘Dy(tBuO)Cl_Ei90.00meV_5K’)
YtBuOCl_Ei90_00meV_5K = mc.Load(Filename=’/home/ecz46986/RB1910185/SPE/Y(tBuO)Cl_Ei90.00meV_5K.nxspe’, OutputWorkspace=‘Y(tBuO)Cl_Ei90.00meV_5K’)
scaled_bg_ws = mc.Scale(InputWorkspace=YtBuOCl_Ei90_00meV_5K, OutputWorkspace=‘scaled_bg_ws’, Factor=‘1.1’)
ws_DytBuOCl_Ei90_00meV_5K_subtracted = mc.Minus(LHSWorkspace=DytBuOCl_Ei90_00meV_5K, RHSWorkspace=scaled_bg_ws, OutputWorkspace=‘Dy(tBuO)Cl_Ei90.00meV_5K_subtracted’)

fig = plt.gcf()
ax = fig.add_subplot(111, projection=“mslice”)
slice_ws = mc.Slice(ws_DytBuOCl_Ei90_00meV_5K_subtracted, Axis1="|Q|,0.28338,13.67972,0.1", Axis2=“DeltaE,-45.0,81.0,0.45”, NormToOne=False)

mesh = ax.pcolormesh(slice_ws, cmap=“jet”)
mesh.set_clim(0,100)
cb = plt.colorbar(mesh, ax=ax)
cb.set_label(‘Intensity (arb. units)’, labelpad=20, rotation=270, picker=5)
ax.set_title(‘Dy(tBuO)Cl_Ei90.00meV_5K_subtracted’)
mc.Show()

#1D plot
import mslice.cli as mc
import mslice.plotting.pyplot as plt

DytBuOCl_Ei90_00meV_5K = mc.Load(Filename=’/home/ecz46986/RB1910185/SPE/Dy(tBuO)Cl_Ei90.00meV_5K.nxspe’, OutputWorkspace=‘Dy(tBuO)Cl_Ei90.00meV_5K’)
YtBuOCl_Ei90_00meV_5K = mc.Load(Filename=’/home/ecz46986/RB1910185/SPE/Y(tBuO)Cl_Ei90.00meV_5K.nxspe’, OutputWorkspace=‘Y(tBuO)Cl_Ei90.00meV_5K’)
scaled_bg_ws = mc.Scale(InputWorkspace=YtBuOCl_Ei90_00meV_5K, OutputWorkspace=‘scaled_bg_ws’, Factor=‘1.1’)
ws_DytBuOCl_Ei90_00meV_5K_subtracted = mc.Minus(LHSWorkspace=DytBuOCl_Ei90_00meV_5K, RHSWorkspace=scaled_bg_ws, OutputWorkspace=‘Dy(tBuO)Cl_Ei90.00meV_5K_subtracted’)

cut_ws_0 = mc.Cut(ws_DytBuOCl_Ei90_00meV_5K_subtracted,CutAxis=“DeltaE,-10.0,90.0,0.2”, IntegrationAxis="|Q|,0.0,4.0,0.0", NormToOne=False)

fig = plt.gcf()
ax = fig.add_subplot(111, projection=“mslice”)

ax.errorbar(cut_ws_0, label=“Dy-cene_Ei9.00meV_130_5K 0.00<|Q|<4.00”, color=“b”, marker=“o”, ls="-", lw=1.0, intensity_range=(0.0, 1000.0))

ax.set_title(’’)
ax.set_ylabel(‘Signal/#Events’)
ax.set_xlabel(‘Energy Transfer (meV)’)
ax.set_ylim(bottom=0.0, top=1000.0)
ax.set_xlim(left=-10, right=90.0)
mc.Show()

Hi Tatiana, I have explored the possibility of plotting multiple workspaces using the same script. The way to go about this is to use the ‘mc.KeepFigure()’ method to stop the subsequent plots from going to the same figure. You also need to initialise the figure and axis (for some reason this one needs a different name) and one call to mc.show() at the end of the script. Here is an example of what I mean.

# Python Script Generated by Mslice on 2019-04-03 16:19:57
import mslice.cli as mc
import mslice.plotting.pyplot as plt

ws_MAR21335_Ei60_00meV = mc.Load(Filename='/home/user/Downloads/mslice_test_data/MAR21335_Ei60.00meV.nxs')

fig = plt.gcf()
ax = fig.add_subplot(111, projection="mslice")

cut_ws_0 = mc.Cut(ws_MAR21335_Ei60_00meV, CutAxis="|Q|,1.0,11.0,1.0", IntegrationAxis="DeltaE,-1.0,0.0,0.0", NormToOne=True)
ax.errorbar(cut_ws_0, label="MAR21335_Ei60.00meV -1.00<E<0.00", color="#1f77b4", marker="o", ls="-", lw=1.5, intensity_range=(0.004932371356818496, 1.0518143597377505))

cut_ws_1 = mc.Cut(ws_MAR21335_Ei60_00meV, CutAxis="|Q|,1.0,11.0,1.0", IntegrationAxis="DeltaE,0.0,1.0,0.0", NormToOne=True)
ax.errorbar(cut_ws_1, label="MAR21335_Ei60.00meV 0.00<E<1.00", color="#ff7f0e", marker="o", ls="-", lw=1.5, intensity_range=(0.004932371356818496, 1.0518143597377505))

ax.set_title('')
ax.set_ylabel("Signal/#Events")
ax.set_ylim(bottom=0.00493237135682, top=1.05181435974)
ax.set_xlim(left=1.1, right=9.9)
mc.KeepFigure()

fig2 = plt.gcf()
ax2 = fig2.add_subplot(111, projection="mslice")
slice_ws = mc.Slice(ws_MAR21335_Ei60_00meV, Axis1="|Q|,0.27356,11.0351,0.04671", Axis2="DeltaE,-30.0,58.2,0.3", NormToOne=False)

mesh = ax2.pcolormesh(slice_ws, cmap="viridis")
mesh.set_clim(0.0, 376.866578322)
cb = plt.colorbar(mesh, ax=ax2)
cb.set_label('Intensity (arb. units)', labelpad=20, rotation=270, picker=5)
ax2.set_title('MAR21335_Ei60.00meV')
mc.Show()