matplotlib / matplotlib/ipympl

Getting back toolbar on left (if set to top position) in 0.8.4?

Ouverte
#411 2 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Langage dominant
Jupyter Notebook
Étoiles
1.7k
Forks
234
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

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 be fade-in-fade-out (apparently, when I documented above hacks, the default was visible).

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):

%matplotlib widget
import ipympl; print("ipympl version {}".format(ipympl.__version__))

import matplotlib.pyplot as plt
from ipywidgets import widgets, Layout
from IPython.display import display, HTML

out_widget_plot = widgets.Output()
with out_widget_plot:
    with plt.style.context("default"): # ggplot
        fig, (ax1) = plt.subplots(1, 1)

fig.suptitle('test title', fontsize=10) 
tline = ax1.plot([0,1,2], [10,20,30])
fig.tight_layout()
#fig.canvas.toolbar.button_style = 'info' # test: ok, works (but don't need it here)
#fig.canvas.toolbar.orientation = 'horizontal' # no error, but no effect either
fig.canvas.toolbar_position = 'top' # this also switches the orientation to horizontal, too
fig.canvas.header_visible = False # Gets rid of "Figure 1" on top

# the below CSS style override in Jupyter, allows the div that hosts the Matplotlib toolbar, to be placed "on top" of the div that hosts the plot:
# widget-label does the same, but for the bottom "x/y" indicator (which is why its position needs to also be controlled with margin)
sthtml = """
<style>
.jupyter-matplotlib-toolbar {
    overflow: visible;
    position: absolute;
    z-index: 1000;
}
.widget-label {
    color: var(--jp-widgets-label-color);
    font-size: var(--jp-widgets-font-size);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: var(--jp-widgets-inline-height);
    z-index: 1000;
    margin-top: -41px;
    margin-left: 58px;
}
</style>
"""

the_ui = widgets.VBox([ widgets.HTML(sthtml), widgets.HTML("<b>Hello</b>"), out_widget_plot, widgets.HTML("<b>World</b>"),])
display(the_ui)

... 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"):

image

... 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

3.8.10 (default, Sep 28 2021, 16:10:42) 
[GCC 9.3.0]
ipympl version: 0.8.4
Selected Jupyter core packages...
IPython          : 7.30.1
ipykernel        : 6.6.0
ipywidgets       : 7.6.5
jupyter_client   : 7.1.0
jupyter_core     : 4.9.1
jupyter_server   : 1.13.1
jupyterlab       : not installed
nbclient         : 0.5.9
nbconvert        : 6.3.0
nbformat         : 5.1.3
notebook         : 6.4.6
qtconsole        : 5.2.2
traitlets        : 5.1.1
Known nbextensions:
  config dir: /usr/local/etc/jupyter/nbconfig
    notebook section
      bqplot/extension  enabled 
      - Validating: OK
      ipysheet/extension  enabled 
      - Validating: OK
      ipyvolume/extension  enabled 
      - Validating: OK
      jupyter-datawidgets/extension  enabled 
      - Validating: OK
      jupyter-leaflet/extension  enabled 
      - Validating: OK
      jupyter-matplotlib/extension  enabled 
      - Validating: OK
      jupyter-threejs/extension  enabled 
      - Validating: OK
      jupyter-webrtc/extension  enabled 
      - Validating: OK
      jupyter_bokeh/extension  enabled 
      - Validating: OK
      jupyter_resource_usage/main  enabled 
      - Validating: OK
      jupyterlab-plotly/extension  enabled 
      - Validating: OK
      voila/extension  enabled 
      - Validating: OK
      jupyter-js-widgets/extension  enabled 
      - Validating: OK
      nbextensions_configurator/config_menu/main  enabled 
      - Validating: problems found:
        - require?  X nbextensions_configurator/config_menu/main
      contrib_nbextensions_help_item/main  enabled 
      - Validating: OK
    tree section
      nbextensions_configurator/tree_tab/main  enabled 
      - Validating: problems found:
        - require?  X nbextensions_configurator/tree_tab/main
usage: jupyter [-h] [--version] [--config-dir] [--data-dir] [--runtime-dir]
               [--paths] [--json] [--debug]
               [subcommand]

Jupyter: Interactive Computing

positional arguments:
  subcommand     the subcommand to launch

optional arguments:
  -h, --help     show this help message and exit
  --version      show the versions of core jupyter packages and exit
  --config-dir   show Jupyter config dir
  --data-dir     show Jupyter data dir
  --runtime-dir  show Jupyter runtime dir
  --paths        show all Jupyter paths. Add --json for machine-readable
                 format.
  --json         output paths as machine-readable json
  --debug        output debug information about paths

Available subcommands: bundlerextension console contrib dejavu execute kernel
kernelspec migrate nbconvert nbextension nbextensions_configurator notebook
qtconsole run server serverextension troubleshoot trust

Jupyter command `jupyter-labextension` not found.

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par exécuter la reproduction fournie avec ipympl 0.8.4 et les versions indiquées de Jupyter et ipywidgets, puis comparez le comportement de la disposition de la barre d’outils et des widgets avec l’exemple précédent. C’est terminé lorsque le positionnement de la barre d’outils en haut à gauche est rétabli, que la figure reste entre les widgets Hello et World et qu’il est déterminé si le contrôle hamburger peut être rétabli.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
jupyter-notebook, python
Domaine
frontend
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.