Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error from editing plot settings in a plot #37358

Closed
GuiMacielPereira opened this issue May 14, 2024 · 4 comments · Fixed by #37380
Closed

Error from editing plot settings in a plot #37358

GuiMacielPereira opened this issue May 14, 2024 · 4 comments · Fixed by #37380
Assignees
Labels
Bug Issues and pull requests that are regressions or would be considered a bug by users (e.g. crashing) ISIS Team: Core Issue and pull requests managed by the Core subteam at ISIS Reported By User Issues that were found or highlighted by a user/scientist
Milestone

Comments

@GuiMacielPereira
Copy link
Contributor

GuiMacielPereira commented May 14, 2024

Original reporter: James Cresswell

Describe the bug
Hiding curves in the settings dialog in a plot caused an error:

  File "/opt/mantidworkbenchnightly/lib/python3.10/site-packages/mantidqt/widgets/plotconfigdialog/presenter.py", line 75, in apply_properties
    tab.apply_properties()
  File "/opt/mantidworkbenchnightly/lib/python3.10/site-packages/mantidqt/widgets/plotconfigdialog/curvestabwidget/presenter.py", line 65, in apply_properties
    self._replot_current_curve(plot_kwargs)
  File "/opt/mantidworkbenchnightly/lib/python3.10/site-packages/mantidqt/widgets/plotconfigdialog/curvestabwidget/presenter.py", line 153, in _replot_current_curve
    ax.add_line(lines_to_remove.pop())
IndexError: pop from empty list

To Reproduce
I asked the user for the data he used and he sent me this folder:
MantidTroubleshooting.zip

The script generated from the faulty plot was the following:

# import mantid algorithms, numpy and matplotlib
from mantid.simpleapi import *
import matplotlib.pyplot as plt
import numpy as np


import matplotlib.pyplot as plt
from mantid.plots.utility import MantidAxType
from mantid.api import AnalysisDataService as ADS

IvsQ_74306_74307_74308 = ADS.retrieve('IvsQ_74306_74307_74308')
IvsQ_74374_74375_74376 = ADS.retrieve('IvsQ_74374_74375_74376')
IvsQ_74324_74325_74326 = ADS.retrieve('IvsQ_74324_74325_74326')
IvsQ_74388_74389 = ADS.retrieve('IvsQ_74388_74389')
IvsQ_74342_74343_74344 = ADS.retrieve('IvsQ_74342_74343_74344')

fig, axes = plt.subplots(edgecolor='#ffffff', num='S12 MS024', subplot_kw={'projection': 'mantid'})
axes.errorbar(IvsQ_74342_74343_74344, capsize=1.0, color='#1f77b4', elinewidth=1.0, label='IvsQ_74342_74343_74344: spec 330', linewidth=1.0, marker='.', markersize=4.0, wkspIndex=0)
axes.errorbar(IvsQ_74324_74325_74326, capsize=1.0, color='#ff7f0e', elinewidth=1.0, label='IvsQ_74324_74325_74326: spec 330', linewidth=1.0, marker='.', markersize=4.0, wkspIndex=0)
axes.errorbar(IvsQ_74306_74307_74308, capsize=1.0, color='#2ca02c', elinewidth=1.0, label='IvsQ_74306_74307_74308: spec 330', linewidth=1.0, marker='.', markersize=4.0, wkspIndex=0)
axes.errorbar(IvsQ_74388_74389, capsize=1.0, color='#e377c2', elinewidth=1.0, label='S12 Si PET MS024 Rinse Lipid Air IvsQ_74388_74389: spec 330', linewidth=1.0, marker='.', markersize=4.0, wkspIndex=0)
axes.errorbar(IvsQ_74374_74375_74376, capsize=1.0, color='#d62728', elinewidth=1.0, label='IvsQ_74374_74375_74376: spec 330', linewidth=1.0, marker='.', markersize=4.0, wkspIndex=0)
axes.minorticks_on()
axes.tick_params(axis='x', which='minor', **{'gridOn': False, 'tick1On': True, 'tick2On': False, 'label1On': True, 'label2On': False, 'size': 0, 'tickdir': 'out', 'width': 1})
axes.tick_params(axis='y', which='minor', **{'gridOn': False, 'tick1On': True, 'tick2On': False, 'label1On': True, 'label2On': False, 'size': 0, 'tickdir': 'out', 'width': 1})
axes.tick_params(axis='x', which='major', **{'gridOn': True, 'tick1On': True, 'tick2On': False, 'label1On': True, 'label2On': False, 'size': 6, 'tickdir': 'out', 'width': 1})
axes.tick_params(axis='y', which='major', **{'gridOn': True, 'tick1On': True, 'tick2On': False, 'label1On': True, 'label2On': False, 'size': 6, 'tickdir': 'out', 'width': 1})
axes.set_title('S12 MS024')
axes.set_xlabel('q ($\\AA^{-1}$)')
axes.set_ylabel('Reflectivity')
axes.set_xlim([0.0079686, 0.39723])
axes.set_ylim([0.0, 3.4784])
axes.set_xscale('log')
axes.set_yscale('log')
legend = axes.legend(fontsize=8.0).set_draggable(True).legend

fig.show()
# Use plt.show() if running the script outside of Workbench
#plt.show()
# Scripting Plots in Mantid:
# https://docs.mantidproject.org/tutorials/python_in_mantid/plotting/02_scripting_plots.html

Then open the plot options dialog.
Select the second or the third curve and click Apply. You should get an error.
If you select and deselect other curves, you should also get an error sometimes.

Expected behavior
No error when selecting or deselecting other curves.
No change of behaviour when changes are applied but nothing was changed in the plotconfigdialog

Screenshots

Platform/Version (please complete the following information):

  • OS: Rocky Linux 8.9 (Green Obsidian)
  • Mantid Version 6.9.20240425.1854
@GuiMacielPereira GuiMacielPereira added Bug Issues and pull requests that are regressions or would be considered a bug by users (e.g. crashing) ISIS Team: Core Issue and pull requests managed by the Core subteam at ISIS Reported By User Issues that were found or highlighted by a user/scientist labels May 14, 2024
@sf1919
Copy link
Contributor

sf1919 commented May 14, 2024

Is this happening in earlier versions of Mantid?

@GuiMacielPereira GuiMacielPereira changed the title Error from clicking on plot settings in a plot Error from editing plot settings in a plot May 14, 2024
@GuiMacielPereira
Copy link
Contributor Author

I tested it and it's not present in 6.8, it appeared in 6.9

@sf1919
Copy link
Contributor

sf1919 commented May 14, 2024

In that case I think we'd best sort it out as a bugfix for v6.10 as it looks pretty small.

@sf1919 sf1919 added this to the Release 6.10 milestone May 14, 2024
@jhaigh0
Copy link
Contributor

jhaigh0 commented May 15, 2024

I recognise that line of code as something I had to change with the mpl update, so probably introduced the problem there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Issues and pull requests that are regressions or would be considered a bug by users (e.g. crashing) ISIS Team: Core Issue and pull requests managed by the Core subteam at ISIS Reported By User Issues that were found or highlighted by a user/scientist
Projects
Status: Done
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants