Skip to content
Open
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
41 changes: 41 additions & 0 deletions rascal2/widgets/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,8 +591,42 @@ def make_control_layout(self):
control_layout.addWidget(QtWidgets.QLabel("Confidence Interval"))
control_layout.addWidget(self.ci_param_box)

self.x_axis = QtWidgets.QComboBox()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of duplicating the controls, please look at making ShadedPlotWidget inherit from RefSLDWidget then you can grab these from super().make_control_layout()

self.x_axis.addItems(["Log", "Linear"])
self.x_axis.currentTextChanged.connect(lambda: self.draw_plot())
self.y_axis = QtWidgets.QComboBox()
self.y_axis.addItems(["Ref", "Q^4"])
self.y_axis.currentTextChanged.connect(lambda: self.draw_plot())
self.show_error_bar = QtWidgets.QCheckBox("Show Error Bars")
self.show_error_bar.setChecked(True)
self.show_error_bar.checkStateChanged.connect(lambda: self.draw_plot())
self.show_grid = QtWidgets.QCheckBox("Show Grid")
self.show_grid.checkStateChanged.connect(lambda: self.draw_plot())
self.show_legend = QtWidgets.QCheckBox("Show Legend")
self.show_legend.setChecked(True)
self.show_legend.checkStateChanged.connect(lambda: self.draw_plot())

control_layout.addWidget(QtWidgets.QLabel("X-Axis"))
control_layout.addWidget(self.x_axis)
control_layout.addWidget(QtWidgets.QLabel("Y-Axis"))
control_layout.addWidget(self.y_axis)
control_layout.addWidget(self.show_error_bar)
control_layout.addWidget(self.show_grid)
control_layout.addWidget(self.show_legend)

return control_layout

def make_toolbar_widget(self):
self.slider = QtWidgets.QSlider(QtCore.Qt.Orientation.Vertical)
self.slider.setTracking(False)
self.slider.setInvertedAppearance(True)
self.slider.setMinimum(0)
self.slider.setMaximum(100)
self.slider.setValue(0)
self.slider.valueChanged.connect(lambda: self.draw_plot())

return self.slider

def plot(self, project, results: ratapi.outputs.BayesResults):
"""Plot the shaded plot."""
self.project = project
Expand All @@ -604,11 +638,18 @@ def draw_plot(self):
"""Plot the shaded reflectivity and SLD profiles."""
self.clear()

show_legend = self.show_legend.isChecked()
ratapi.plotting.plot_ref_sld(
self.project,
self.results,
bayes=int(self.ci_param_box.currentText().strip("%")),
fig=self.figure,
linear_x=self.x_axis.currentText() == "Linear",
q4=self.y_axis.currentText() == "Q^4",
show_error_bar=self.show_error_bar.isChecked(),
show_grid=self.show_grid.isChecked(),
show_legend=show_legend,
shift_value=self.slider.value(),
)
self.canvas.draw()

Expand Down
Loading