Skip to content

Commit ef677e7

Browse files
Layout axes remain the same after update_plot methods is called (#904)
* increasing fat_bands_slide/ removing spline
1 parent 15f46b0 commit ef677e7

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/aiidalab_qe/common/bandpdoswidget.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,12 +744,24 @@ def _update_plot(self, _=None):
744744
else:
745745
self.pdos_data = self._get_pdos_data()
746746
self.bands_data = self._get_bands_data()
747+
748+
# Get current axis range
749+
xaxis_range = list(self.bandsplot_widget.layout["xaxis"]["range"])
750+
yaxis_range = list(self.bandsplot_widget.layout["yaxis"]["range"])
751+
747752
self.bandsplot_widget = BandPdosPlotly(
748753
bands_data=self.bands_data,
749754
pdos_data=self.pdos_data,
750755
project_bands=self.project_bands_box.value,
751756
).bandspdosfigure
752757
self._clear_output_and_display(self.bandsplot_widget)
758+
759+
# Restore Old axis range. I do it after the plot is displayed to the Reset button always return to the Default SETTINGs
760+
if self.bands_data:
761+
self.bandsplot_widget.plotly_relayout({"yaxis.range": yaxis_range})
762+
if self.pdos_data and not self.bands_data:
763+
self.bandsplot_widget.plotly_relayout({"xaxis.range": xaxis_range})
764+
753765
self.proj_bands_width_slider.layout.visibility = (
754766
"visible" if self.project_bands_box.value else "hidden"
755767
)

0 commit comments

Comments
 (0)