Open perenon opened 8 months ago
Works also with this script
# import mantid algorithms, numpy and matplotlib
from mantid.simpleapi import *
import matplotlib.pyplot as plt
import numpy as np
# Load the data
run = Load('Training_Exercise3a_SNS.nxs')
fig, axes = plt.subplots(subplot_kw={'projection': 'mantid'})
# Choose legend labels and colors for each curve
labels = ("sp-1", "sp-2", "sp-3", "sp-4", "sp-5")
colors = ('#FFCFC4', '#FE886F','#FE4A23', '#B82405', '#6A1300')
# Plot the first 5 spectra
for i in range(5):
axes.plot(run, wkspIndex=i, color=colors[i], label=labels[i])
# Plot the 9th spectrum with errorbars
axes.errorbar(run, specNum=9, capsize=2.0, color='blue', label='Peak of Interest', linewidth=1.0)
# Set the X-axis limts and the Y-axis scale
axes.set_xlim(-1.5, 1.8)
plt.yscale('log')
# Give the plot a title
plt.title("Peak Evolution", fontsize=20)
# Add a legend with the chosen labels and show the plot
axes.legend()
#plt.show() #uncomment to show the plot
# Note with the Direct Matplotlib method,
# there are many more options for formatting the plot
We should stop users from using plt.show()
and ask them to use fig.show()
Hi Andrei. Thanks, that solves the whole problem for the two issues described above.
Apparently, there is a PR here to change the code generation in that way. We should also update documentation.
This will be something to look into,
Describe the bug If running
plt.show()
in a script editor, the editor comes to a state where it cannot be edited anymore.To Reproduce Open mantidworkbench
In the editor, type this:
Run the script, the plots appear.
Uncomment the last line, run once again. The plot will also appear, but the editor will not be editable anymore.
Closing the tab makes things back to normal.
Expected behavior
The editor should be editable.
Screenshots
Platform/Version (please complete the following information):
Additional context Found in smoke testing for the 6.9 release, https://github.com/mantidproject/mantid/issues/36877.