matplotlib / matplotlib/matplotlib

[Bug]: mpl.style.context() stops plotting inline in Jupyter

オープン
#26,716 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

topic: backends
主要言語
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:
![image](https://github.com/matplotlib/matplotlib/assets/143531681/d885aa2b-9f65-4df3-afcb-485cae9b2714)

CASE 2:
![image](https://github.com/matplotlib/matplotlib/assets/143531681/b82b505e-4629-4ba0-b2a1-06cbf8012665)

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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. 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

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。