matplotlib / matplotlib/matplotlib
[BUG]: Neither explicit data limit is respected when `constrained_layout` is used together with `set_aspect(..., "datalim")`
還沒有人認領這個 Issue。
- 主要語言
- Python
- 星號
- 23.2k
- 分支
- 8.5k
- 平均合併
- 1 天 6 小時
- 30 天內合併 PR
- 66
描述
Edit: This description was written when this was still considered an enhancement request. It turned out that the feature in question already is available, but in certain circumstances doesn't work correctly.
Problem
This is an extension of #28673. The problem is that once a user has request set_aspect("equal"), there is no good API left to further refine the axis limit, i.e. to pan and more importantly, zoom the plot. I believe there is room for improvement here.
The request a user may have is: "set X limits to the specified values, and give me some Y limits which respect the aspect ratio" (you may obviously swap X and Y here). The problem matplotlib has is that this request leaves one degree of freedom ambiguous, with no help from the user to choose - so currently, matplotlib refuses to follow-up on that request. But the problem the user has is that conversely, there is no API to help matplotlib here to specify just that one degree of freedom (typically, the implied request is: "keep the middle in the middle"). The only option left to the user is to discard the request for equal aspect, supply two degrees of freedom and painstakingly do the aspect computations temselves as shown in the workaroung in a comment to the previous issue by @kjayawar.
Perhaps we could come up with a suitable API here? Say, fix the X axis limits and specify the Y coordinate of the centre? Or specify axis limits for either or both dimensions, and allow the user to opt-in for either cropping or extending one of the two if needed while keeping the middle in the centre?
Proposed solution
No response
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
issue 中沒有指定檔案、測試或具體的重現步驟。首先重現 constrained_layout、set_aspect(..., "datalim") 與明確座標軸限制之間的互動,然後追蹤現有的 aspect 與版面配置處理。完成標準是:在這種組合下,兩個明確限制都受到遵守,並且針對所回報行為具有回歸測試涵蓋。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- data-visualization
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 需要釐清
- 新手友好度
- 25/100