matplotlib / matplotlib/ipympl

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

Đang mở
#411 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
Jupyter Notebook
Star
1.7k
Fork
234
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng cách chạy bản tái hiện được cung cấp với ipympl 0.8.4 và các phiên bản Jupyter và ipywidgets được liệt kê, sau đó so sánh hành vi bố cục của thanh công cụ và widget với ví dụ trước đó. Được xem là hoàn tất khi khôi phục vị trí thanh công cụ ở góc trên bên trái, giữ figure giữa các widget Hello và World, đồng thời xác định liệu có thể khôi phục điều khiển hamburger hay không.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
jupyter-notebook, python
Lĩnh vực
frontend
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.