Skip to content

Commit

Permalink
Merge pull request #75 from PaNOSC-ViNYL/new_widget_layout
Browse files Browse the repository at this point in the history
Fixed issue with placement of plot in widget on newer ipywidget
  • Loading branch information
mads-bertelsen authored Dec 1, 2023
2 parents f8e17f3 + d4dced8 commit 0e64e0e
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions mcstasscript/jb_interface/plot_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,15 @@ def new_plot(self):
Sets up original plot with fig, ax and ax for colorbar
"""
# fig, ax = plt.subplots(constrained_layout=True, figsize=(6, 4))

self.fig, (self.ax, self.colorbar_ax) = plt.subplots(ncols=2,
gridspec_kw={'width_ratios': [6, 1]})
gridspec_kw={'width_ratios': [6, 1]},
tight_layout=True)

self.fig.canvas.toolbar_position = 'bottom'

plt.show()

self.update_plot()

def update_plot(self):
Expand Down Expand Up @@ -162,19 +166,21 @@ def update_plot(self):
else:
self.colorbar_ax.set_axis_off()

#self.ax.set_axis_on()

plt.tight_layout()
self.fig.canvas.draw()

def show_interface(self):
"""
Show the plot interface
"""
# turn off automatic plotting
plt.ioff()

# Set up plot area
output = widgets.Output()

with output:
self.new_plot()

output.layout = widgets.Layout(width="75%")

# could retrieve default plot options from data if given
Expand All @@ -201,14 +207,13 @@ def show_interface(self):
plot_control_list.append(colormap_control.make_widget())

plot_controls = widgets.VBox(plot_control_list,
#layout=widgets.Layout(width="25%", border="solid"))
layout=widgets.Layout(width="25%"))

# In case data is already supplied, set it
if self.data is not None:
self.set_data(self.data)

return widgets.HBox([output, plot_controls], layout=widgets.Layout(width="100%"))
return widgets.HBox([output, plot_controls])


class ColormapDropdown:
Expand Down

0 comments on commit 0e64e0e

Please sign in to comment.