{"record":{"id":"45021e2058d4bfce","repo":"matplotlib/matplotlib","slug":"unknown-value-for-which-which-r","errorCode":null,"errorMessage":"unknown value for which: {which!r}","messagePattern":"unknown value for which: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"lib/matplotlib/axes/_base.py","lineNumber":1009,"sourceCode":"            This transformation is primarily used by the\n            `~matplotlib.axis.Axis` class, and is meant to be\n            overridden by new kinds of projections that may need to\n            place axis elements in different locations.\n\n        Parameters\n        ----------\n        which : {'grid', 'tick1', 'tick2'}\n        \"\"\"\n        if which == 'grid':\n            return self._xaxis_transform\n        elif which == 'tick1':\n            # for cartesian projection, this is bottom spine\n            return self.spines.bottom.get_spine_transform()\n        elif which == 'tick2':\n            # for cartesian projection, this is top spine\n            return self.spines.top.get_spine_transform()\n        else:\n            raise ValueError(f'unknown value for which: {which!r}')\n\n    def get_xaxis_text1_transform(self, pad_points):\n        \"\"\"\n        Returns\n        -------\n        transform : Transform\n            The transform used for drawing x-axis labels, which will add\n            *pad_points* of padding (in points) between the axis and the label.\n            The x-direction is in data coordinates and the y-direction is in\n            axis coordinates\n        valign : {'center', 'top', 'bottom', 'baseline', 'center_baseline'}\n            The text vertical alignment.\n        halign : {'center', 'left', 'right'}\n            The text horizontal alignment.\n\n        Notes\n        -----\n        This transformation is primarily used by the `~matplotlib.axis.Axis`","sourceCodeStart":991,"sourceCodeEnd":1027,"githubUrl":"https://github.com/matplotlib/matplotlib/blob/b379c1b69e012b142c0f496a52bcb30513802d72/lib/matplotlib/axes/_base.py#L991-L1027","documentation":"get_xaxis_transform(which) selects among three transforms for x-axis artists — 'grid' (blended data/axes coordinates), 'tick1' (bottom spine), 'tick2' (top spine); any other value is rejected (lib/matplotlib/axes/_base.py:1009).","triggerScenarios":"ax.get_xaxis_transform(which='bottom'), which='x', which='ticks' — anything outside {'grid', 'tick1', 'tick2'}.","commonSituations":"Using spine names ('bottom'/'top') instead of tick1/tick2; guessing the API from get_spine_transform or set_position; copied code adjusted for non-cartesian axes.","solutions":["Use 'grid', 'tick1' (bottom spine), or 'tick2' (top spine)","For a spine transform directly, call ax.spines['bottom'].get_spine_transform()","For the default blended transform just call ax.get_xaxis_transform() with no argument (defaults to 'grid')"],"exampleFix":"# before\ntr = ax.get_xaxis_transform(which='bottom')\n# after\ntr = ax.get_xaxis_transform(which='tick1')  # bottom spine","handlingStrategy":"validation","validationCode":"_VALID_WHERE = {'grid', 'tick1', 'tick2'}\n\nassert which in _VALID_WHERE, f'which must be one of {sorted(_VALID_WHERE)}, got {which!r}'\ntr = ax.get_xaxis_transform(which=which)","typeGuard":"def is_valid_which(w) -> bool:\n    return w in {'grid', 'tick1', 'tick2'}","tryCatchPattern":null,"preventionTips":["Read the docstring's which : {'grid', 'tick1', 'tick2'} line before calling","Map spine names to tick ids: bottom -> tick1, top -> tick2","Centralize transform selection in one helper with an allow-list"],"tags":["matplotlib","axes","transform","enum","validation"],"backgroundTag":"invalid-parameter-value","analyzedSha":"b379c1b69e012b142c0f496a52bcb30513802d72","analyzedAt":"2026-08-21T23:31:55.468Z","schemaVersion":2},"datasetVersion":"2026-08-22T04:17:13.399Z"}