matplotlib / matplotlib/ipympl

"Transform()" returns bad coordinates with ipympl

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

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

主要言語
Jupyter Notebook
スター
1.7k
フォーク
234
PR マージ指標
30日以内にマージされた PR はありません

説明

## Describe the issue

I believe the "transform()" functions of Matplotlib do not behave well in ipympl or widget mode.

**Code for reproduction**

I simply use the matplotlib example published here:
https://matplotlib.org/3.1.1/tutorials/advanced/transforms_tutorial.html

I copy/paste the code for basic help :
```python
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches

x = np.arange(0, 10, 0.005)
y = np.exp(-x/2.) * np.sin(2*np.pi*x)

fig, ax = plt.subplots()
ax.plot(x, y)
ax.set_xlim(0, 10)
ax.set_ylim(-1, 1)

xdata, ydata = 5, 0
xdisplay, ydisplay = ax.transData.transform_point((xdata, ydata))

bbox = dict(boxstyle="round", fc="0.8")
arrowprops = dict(
arrowstyle="->",
connectionstyle="angle,angleA=0,angleB=90,rad=10")

offset = 72
ax.annotate('data = (%.1f, %.1f)' % (xdata, ydata),
(xdata, ydata), xytext=(-2*offset, offset), textcoords='offset points',
bbox=bbox, arrowprops=arrowprops)

disp = ax.annotate('display = (%.1f, %.1f)' % (xdisplay, ydisplay),
(xdisplay, ydisplay), xytext=(0.5*offset, -offset),
xycoords='figure pixels',
textcoords='offset points',
bbox=bbox, arrowprops=arrowprops)

plt.show()
```

**Actual outcome**
I get different results depending on the matplotlib mode :
- on one side, %matplotlib inline gives the result expected and displayed in the example, as below :
![download](https://user-images.githubusercontent.com/65092924/89292441-ab730a80-d65c-11ea-8307-6861d50bd587.png)
- on the other side, %matplotlib ipympl or %matplotlib widget give erroneous results, as below :
widget
The result is the same if I download with the "floppy-disk" icon of the widget.

**Expected outcome**

The result with widget or ipympl mode should be the one of inline mode.

## Versions

```
3.7.7 (default, Mar 26 2020, 10:32:53)
[Clang 4.0.1 (tags/RELEASE_401/final)]
ipympl version: 0.5.2
jupyter core : 4.6.3
jupyter-notebook : 6.0.3
qtconsole : 4.7.5
ipython : 7.16.1
ipykernel : 5.3.3
jupyter client : 6.1.6
jupyter lab : 1.2.6
nbconvert : 5.6.1
ipywidgets : 7.5.1
nbformat : 5.0.7
traitlets : 4.3.3
Known nbextensions:
config dir: /Users/mmyara/.jupyter/nbconfig
notebook section
jupyter-js-widgets/extension enabled
- Validating: OK
config dir: /opt/miniconda3/etc/jupyter/nbconfig
notebook section
jupyter-matplotlib/extension enabled
- Validating: OK
plotlywidget/extension enabled
- Validating: OK
jupyter-js-widgets/extension enabled
- Validating: OK
tree section
ipyparallel/main enabled
- Validating: OK
JupyterLab v1.2.6
Known labextensions:
app dir: /opt/miniconda3/share/jupyter/lab
@jupyter-widgets/jupyterlab-manager v1.1.0 enabled OK
@jupyterlab/toc v2.0.0 enabled OK
@lckr/jupyterlab_variableinspector v0.4.0 enabled OK
jupyter-matplotlib v0.7.1 enabled OK
jupyterlab-plotly v4.9.0 enabled OK
plotlywidget v4.9.0 enabled OK```

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

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

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、提供されている Matplotlib の transform の例を inline モードと ipympl/widget モードで実行し、表示された結果と保存された結果を比較します。widget モードで inline モードと同じ座標およびアノテーションの配置が生成されれば、issue は完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
jupyter, jupyter-notebook, python
領域
frontend, web-dev
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
38/100

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

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