Open sdbbs opened 2 years ago
Thanks for opening an issue. Please keep in mind that the CSS is not considered as public API in ipympl, so if you do some hacks in the CSS they might not work from one version to the other.
There have been some changes on the Toolbar recently though. So you now have new properties that will change the visibility of the toolbar:
fig.canvas.toolbar_visible = 'fade-in-fade-out' # Default: will only show the toolbar when the mouse is on top of the plot
fig.canvas.toolbar_visible = False # Always hidden
fig.canvas.toolbar_visible = True # Always visible
But you also can change its position:
fig.canvas.toolbar_position = 'left' # Default
fig.canvas.toolbar_position = 'right'
fig.canvas.toolbar_position = 'top'
fig.canvas.toolbar_position = 'bottom'
Now if you want the toolbar back on the top-left, I would suggest to set the toolbar_position
property to 'top'
and this CSS hack:
sthtml = """
<style>
.jupyter-matplotlib-toolbar {
inset: 3px auto auto 3px;
}
</style>
"""
Also, if you want to display the plot between widgets. I'd suggest not using the Output
widget, and instead, turn off the interactive mode:
plt.ioff()
Then use the canvas widget where you need it:
VBox((HTML(), fig.canvas, IntSlider()))
Concerning the last point, ipympl deserves a proper documentation for sure. I will try to find time to work on this.
Describe the issue
In an earlier version of ipympl (unfortunately, haven't recorded which), if I chose the positioning of the toolbar on top, it was automatically placed on the left; I have a partial record of that here - https://stackoverflow.com/questions/69106967/jupyter-matplotlib-widget-place-toolbar-horizontally-over-plot
However, I made an update recently, and it turns out, the hacks that I have documented previously, do not work anymore - also because now the default for
fig.canvas.toolbar_visible
seems to befade-in-fade-out
(apparently, when I documented above hacks, the default wasvisible
).So now, if you run the last code snippet in the answer of the linked SO post above (only thing I added was version printout):
... you at first do not get any toolbar menu (because due to the
fade-in-fade-out
, the menu is not shown, if the mouse cursor is not over the plot widget), then when you mouseover, you get the toolbar to the right (and there is no "hamburger" icon at first, that used to collapse/expand the rest of the toolbar; and the plot figure rendered after the two HTML "labels", "Hello" and "World"):... whereas the same code earlier showed a toolbar on the left (and there is "hamburger" icon at first, that used to collapse/expand the rest of the toolbar, shown; and the plot being rendered between the two HTML "labels") :
Note also that now, the figure plot widget is not shown anymore between the "Hello" and the "World" labels - whereas previously it was (which was the intention).
Is there any way I can get the old behavior back, so I can place the toolbar on the top left, and have the figure shown between other widgets (and possibly get the "hamburger" expand/collapse button back)?
Versions