matplotlib / matplotlib/matplotlib
[Bug]: bad autolimit behavior with fill_between and transforms
還沒有人認領這個 Issue。
- 主要語言
- Python
- 星號
- 23.2k
- 分支
- 8.5k
- 平均合併
- 1 天 6 小時
- 30 天內合併 PR
- 66
描述
### Bug summary
Using a fill_between artist with a custom transform to displace data along the y-axis, the autolimiting behavior does not work as I would expect: the axes use the non-transformed data extents. A normal line plot with the same transform does work as I would expect: autolimits match the transformed data.
### Code for reproduction
```python
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.transforms import Transform
class TransformDemo(Transform):
def __init__(self):
super().__init__()
self.input_dims = 2
self.output_dims = 2
self.is_separable = False
def transform_non_affine(self, values):
output = np.empty_like(values)
output[:, 0] = values[:, 0]
output[:, 1] = 100 + values[:, 1] / (1 + np.abs(values[:, 0]))
return output
# Make some random data
y = np.random.randn(1000)
x = np.arange(len(y))
fig, ax = plt.subplots(ncols=2)
T = TransformDemo()
# First with plot, everything works as expected
ax[0].plot(x, y, transform=T + ax[0].transData)
# With fill_between, limits are not inferred correctly
ax[1].fill_between(x, -np.abs(y), np.abs(y), transform=T + ax[1].transData)
```
### Actual outcome

### Expected outcome
If I force the ylimits on the second plot via
```python
ax[1].set_ylim(ax[0].get_ylim())
```
it looks like

which is basically how I would expect.
### Additional information
I'm not sure that the plot behavior is actually to spec here, but the disagreement between the two artists' behavior seems to me like a bug somewhere.
### Operating system
Ubuntu
### Matplotlib Version
3.5.0
### Matplotlib Backend
module://matplotlib_inline.backend_inline
### Python version
sys.version_info(major=3, minor=9, micro=7, releaselevel='final', serial=0)
### Jupyter version
3.2.5 (dev), 3.2.4 (app)
### Installation
conda
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
首先執行提供的 Python 重現程式碼,並比較 plot 與 fill_between 在都使用自訂 TransformDemo 和 ax.transData 時的 autolimit 行為。追蹤 fill_between artist 的限制計算並加入回歸測試;當經過轉換的 fill_between 資料產生與經過轉換的折線圖一致的限制時,即表示完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- data-visualization
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 42/100