fix: handle horizontal vs vertical bar plot orientation in subplot iteration#243
fix: handle horizontal vs vertical bar plot orientation in subplot iteration#243Copilot wants to merge 3 commits into
Conversation
…eration Co-authored-by: jooyoungseo <19754711+jooyoungseo@users.noreply.github.com>
7e80e35 to
c81c34a
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a critical bug where maidr.show() would fail with a TypeError: 'NoneType' object is not iterable when used with horizontal bar plots. The issue stemmed from incorrect axis label extraction logic that didn't account for plot orientation differences.
Key changes:
- Added orientation-aware axis selection for extracting category labels (Y-axis for horizontal bars, X-axis for vertical bars)
- Updated value extraction to use appropriate dimension based on orientation (width for horizontal, height for vertical)
- Enhanced error handling with null checks and fallback label generation
| """ | ||
| Extract plot data for bar plots. | ||
|
|
||
| For vertical bar plots, categories are on X-axis and values on Y-axis. | ||
| For horizontal bar plots, categories are on Y-axis and values on X-axis. | ||
|
|
||
| Returns | ||
| ------- | ||
| list | ||
| List of dictionaries containing x and y data points. | ||
| """ |
There was a problem hiding this comment.
The docstring follows a good structure but is missing the Parameters section. According to PEP 257 and NumPy style guidelines, even if a method has no parameters, it's better to be explicit about this in the docstring format for consistency.
| """ | ||
| Extract bar container data with proper orientation handling. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| plot : list[BarContainer] | None | ||
| List of bar containers from the plot. | ||
|
|
||
| Returns | ||
| ------- | ||
| list | None | ||
| List of bar heights/widths, or None if extraction fails. | ||
| """ |
There was a problem hiding this comment.
The docstring is well-structured and follows NumPy style guidelines. However, it would benefit from adding an example section showing how to use this method, especially given the complexity of handling different orientations.
|
@copilot Address review comments. |
Co-authored-by: jooyoungseo <19754711+jooyoungseo@users.noreply.github.com>
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.