name: debug_axes description: プロットのスケール(対数軸など)、目盛、表示範囲の不具合を診断し、意図した見た目に修正する
Debug Plot Axes Skill
This skill is for resolving issues where plot axis scales (especially log scales) or display ranges (ylim/xlim) in gwexpy do not appear as intended.
Diagnostic Procedures
-
Verify Internal State:
- Create a reproduction script and output
ax.get_yscale()orax.get_ylim()to confirm if the internal setting is actually 'log'.
- Create a reproduction script and output
-
Identity Visual Linearity Issues:
- If the internal state is 'log' but it visually appears linear, it is often due to the data range being too narrow (e.g., 1.0 vs 2.23).
- Check if ticks are appropriately placed via
ax.get_yticks().
-
Confirm Judgment Logic:
- Check if
determine_yscaleordetermine_xscaleingwexpy/plot/defaults.pycorrectly recognizes the data, using debug prints if necessary.
- Check if
Correction Guidelines
-
Enforce Scale Application:
- Explicitly call
ax.set_yscale()aftersuper().__init__withinPlot.__init__ingwexpy/plot/plot.py. - Always call
ax.autoscale_view()after application to force a visual update.
- Explicitly call
-
Automatic Range Expansion (Log Scale specific):
- If the data range is less than 100x (2 orders of magnitude), log scales often show few ticks, appearing linear.
- Implement or fix
determine_ylimlogic to ensure a range of approximately 2 orders of magnitude centered around the median.
-
Robust Type Checking:
- Since
isinstancechecks may fail due to environment differences (import sources), use duck-typing such astype(obj).__name__orhasattr(obj, 'frequencies')alongside it.
- Since
-
Prevent Duplicate Display in IPython/Jupyter:
- Set
_repr_html_ = Nonein thePlotclass to prevent duplicate displays (repr andplt.show).
- Set