{"record":{"id":"f359a59177f8b40f","repo":"matplotlib/matplotlib","slug":"markevery-tuple-must-be-pair-of-ints-or-of-float","errorCode":null,"errorMessage":"'markevery' tuple must be pair of ints or of floats","messagePattern":"'markevery' tuple must be pair of ints or of floats","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"lib/matplotlib/rcsetup.py","lineNumber":596,"sourceCode":"    Parameters\n    ----------\n    s : None, int, (int, int), slice, float, (float, float), or list[int]\n\n    Returns\n    -------\n    None, int, (int, int), slice, float, (float, float), or list[int]\n    \"\"\"\n    # Validate s against type slice float int and None\n    if isinstance(s, (slice, float, int, type(None))):\n        return s\n    # Validate s against type tuple\n    if isinstance(s, tuple):\n        if (len(s) == 2\n                and (all(isinstance(e, int) for e in s)\n                     or all(isinstance(e, float) for e in s))):\n            return s\n        else:\n            raise TypeError(\n                \"'markevery' tuple must be pair of ints or of floats\")\n    # Validate s against type list\n    if isinstance(s, list):\n        if all(isinstance(e, int) for e in s):\n            return s\n        else:\n            raise TypeError(\n                \"'markevery' list must have all elements of type int\")\n    raise TypeError(\"'markevery' is of an invalid type\")\n\n\nvalidate_markeverylist = _listify_validator(validate_markevery)\n\n\ndef validate_bbox(s):\n    if isinstance(s, str):\n        s = s.lower()\n        if s == 'tight':","sourceCodeStart":578,"sourceCodeEnd":614,"githubUrl":"https://github.com/matplotlib/matplotlib/blob/b379c1b69e012b142c0f496a52bcb30513802d72/lib/matplotlib/rcsetup.py#L578-L614","documentation":"validate_markevery() runs over the 'markevery' key of axes.prop_cycle (via validate_markeverylist). A tuple markevery must be a pair of exactly two elements and homogeneous: both int (subsample start/stride) or both float (start/stop fraction). A 2-tuple mixing int and float, or any tuple of another length, raises this TypeError.","triggerScenarios":"Building plt.rc('axes', prop_cycle=cycler(markevery=[(0, 10)])) correctly, but [(0, 0.1)], [(0.1, 10)], or [(0, 1, 2)] raise. Note bool counts as int, so (True, 5) slips through.","commonSituations":"Converting an interval spec from user config into a markevery tuple without normalizing types; mixing a 0-based index with a fraction in one pair after refactoring.","solutions":["Use an int pair for index-based subsampling: (0, 10) = every 10th marker starting at index 0","Or a float pair for fractional positions: (0.1, 0.5) = markers between 10%-50% of the line","Normalize mixed pairs before building the cycler: tuple(int(x) for x in pair) or tuple(float(x) for x in pair)"],"exampleFix":"# before\nfrom cycler import cycler\nimport matplotlib.pyplot as plt\nplt.rc('axes', prop_cycle=cycler(markevery=[(0, 0.1)]))  # mixed types\n\n# after\nplt.rc('axes', prop_cycle=cycler(markevery=[(0.0, 0.1)]))","handlingStrategy":"type-guard","validationCode":"def valid_markevery(s):\n    if isinstance(s, (slice, float, int, type(None))):\n        return True\n    if isinstance(s, tuple):\n        return (len(s) == 2\n                and (all(type(e) is int for e in s)\n                     or all(type(e) is float for e in s)))\n    if isinstance(s, list):\n        return all(type(e) is int for e in s)\n    return False\n\nassert valid_markevery((0, 10))\nassert not valid_markevery((0, 0.1))","typeGuard":"def is_markevery_pair(v) -> bool:\n    return (isinstance(v, tuple) and len(v) == 2\n            and (all(isinstance(e, int) and not isinstance(e, bool) for e in v)\n                 or all(isinstance(e, float) for e in v)))","tryCatchPattern":"from cycler import cycler\ntry:\n    plt.rc('axes', prop_cycle=cycler(markevery=[me]))\nexcept TypeError as e:\n    me = (int(me[0]), int(me[1]))\n    plt.rc('axes', prop_cycle=cycler(markevery=[me]))","preventionTips":["Keep markevery pairs homogeneous: (int, int) or (float, float), never mixed","Normalize numeric config values to int or float explicitly before building cyclers","Remember pairs are length-2 only; longer tuples are not supported"],"tags":["matplotlib","markevery","prop-cycle","rcparams"],"backgroundTag":"invalid-markevery","analyzedSha":"b379c1b69e012b142c0f496a52bcb30513802d72","analyzedAt":"2026-08-21T23:31:55.468Z","schemaVersion":2},"datasetVersion":"2026-08-22T04:17:13.399Z"}