matplotlib / matplotlib/matplotlib
[Bug]: mpl.style.context() stops plotting inline in Jupyter
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 23.2k
- フォーク
- 8.5k
- 平均マージ
- 1日 6時間
- マージ済み PR(30日)
- 66
説明
### Bug summary
Under certain circumstances, when using matplotlib.style.context() to temporarily alter the default style in a Jupyter notebook, it resets the backend to no plot inline. This occurs if the plot is the first one in the notebook, but not if another plot (without the context manager) has already been plotted.
### Code for reproduction
```python
# CASE 1:
# first cell - produces inline plot with desired grid
import matplotlibl.pyplot as pl
with plt.style.context({'axes.grid': True}):
plt.plot(range(10))
# second cell - does not produce in line plot
plt.plot(range(10))
# CASE 2:
# first cell - produces inline plot
import matplotlibl.pyplot as plt
plt.plot(range(10))
# second cell - produces inline plot with desired grid
with plt.style.context({'axes.grid': True}):
plt.plot(range(10))
# third cell - produces in line plot
plt.plot(range(10))
```
### Actual outcome
CASE 1:

CASE 2:

### Expected outcome
In case 1, the second plot should be inline
### Additional information
_No response_
### Operating system
Windows 10.0.19045 Build 19045
### Matplotlib Version
3.7.2
### Matplotlib Backend
'module://matplotlib_inline.backend_inline'
### Python version
3.10.10
### Jupyter version
6.4.12
### Installation
pip
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
報告されている Matplotlib、Python、inline backend のバージョンを使って、2つのケースを Jupyter notebook で再現します。matplotlib.style.context() と module://matplotlib_inline.backend_inline との相互作用から始めます。ケース1の2つ目のプロットが inline のままになり、その一連の処理をカバーする回帰テストがあれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- jupyter, python
- 領域
- data-visualization
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100