ipython / ipython/ipykernel

activate_matplotlib() is not called.

Đang mở
#247 2 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Python
Star
734
Fork
412
Merge trung bình
1 ngày 5 giờ
Pull request đã merge (30 ngày)
8

Mô tả

## Summary

Unless you intentionally omitted it, It seems to need to call ``IPython.core.pylabtools.activate_matplotlib()`` function in ``_enable_matplotlib_integration()``.

## Details

[Since version 4.4.0](https://github.com/ipython/ipykernel/blob/523cb549add6e2d5984a831582eaabd9c9af6aa3/docs/changelog.rst#440), the default backend has been changed to ``inline`` (``module://ipykernel.pylab.backend_inline``). In this issue, it's called *default inline mode*.

Consequently, we no longer need to specify inline mode using `%matplotlib inline` with Jupyter Notebook. The mode when using the magic command is called *explicit inline mode*.

However, I've realized that the behavior of default inline mode and that of explicit inline mode are different.

1. the behavior of default inline mode

```python
from matplotlib import pyplot as plt

x = [1, 2, 3]
y = [3, 6, 9]

fig = plt.figure()
ax = fig.add_subplot(111)
ax.set_title('Sample Bar Chart')
```

![default-inline](https://cloud.githubusercontent.com/assets/1491856/26275492/c7ab4110-3d9c-11e7-9118-7da789bd14ea.png)

The figure is not rendered when a code-cell is executed. To render a graph, I have to call``plt.show()``.

2. In the case of explicitly inline mode.

```python
from matplotlib import pyplot as plt
%matplotlib inline

x = [1, 2, 3]
y = [3, 6, 9]

fig = plt.figure()
ax = fig.add_subplot(111)
ax.set_title('Sample Bar Chart')
```

![explicityly-inilne](https://cloud.githubusercontent.com/assets/1491856/26275494/cf08bc1c-3d9c-11e7-9f72-7d4c295741c8.png)

The figure is rendered even if ``plot.show()`` is not executed.

I don't know whether these behaviors are correct or not. On the other hand, I think that users are confused by it.

## Proposals

When ``%matplotlib inline`` is called, ``configure_inline_support()`` function and ``activate_matplotlib()`` are executed [^1] . But in `_enable_matplotlib_integration()`, ``activate_matplotlib()`` is not called.

Therefor, maybe simply it should be called in the Initialization process.

Could you tell me your opinion?

[^1]: https://github.com/ipython/ipython/blob/3be8fc96b227125f2dc79fc881f77b5b4e9652fb/IPython/core/interactiveshell.py#L2919

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

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

Đánh giá

Issue này chưa được đánh giá.

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.