{"record":{"id":"53efd2c7acbc3be0","repo":"OpenBB-finance/OpenBB","slug":"this-method-supports-up-to-2-y-axis-units-please","errorCode":null,"errorMessage":"This method supports up to 2 y-axis units. Please use the 'transform' parameter, in the data request, to compare all series on the same scale, or set `normalize = True`. Override this error by setting `allow_unsafe = True`.","messagePattern":"This method supports up to 2 y-axis units\\. Please use the 'transform' parameter, in the data request, to compare all series on the same scale, or set `normalize = True`\\. Override this error by setting `allow_unsafe = True`\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"openbb_platform/extensions/economy/openbb_economy/economy_views.py","lineNumber":112,"sourceCode":"\n        # Get a unique list of all units of measurement in the DataFrame.\n        y_units = list({metadata.get(col).get(\"units\") for col in columns if col in metadata})  # type: ignore\n        if has_params is True and not y_units:\n            y_units = [ytitle_dict.get(params.transform)]  # type: ignore\n\n        if normalize or (\n            kwargs.get(\"bar\") is True\n            and len(y_units) > 1\n            and (\n                has_params is False\n                or not any(i in params.transform for i in [\"pc1\", \"pch\", \"pca\", \"cch\", \"cca\", \"log\"])  # type: ignore\n            )\n        ):\n            normalize = True\n            df_ta = df_ta.apply(z_score_standardization)\n\n        if len(y_units) > 2 and has_params is False and allow_unsafe is False:\n            raise RuntimeError(\n                \"This method supports up to 2 y-axis units.\"\n                + \" Please use the 'transform' parameter, in the data request,\"\n                + \" to compare all series on the same scale, or set `normalize = True`.\"\n                + \" Override this error by setting `allow_unsafe = True`.\"\n            )\n\n        y1_units = y_units[0] if y_units else None\n        y1title = y1_units\n        y2title = y_units[1] if len(y_units) > 1 else None\n        xtitle = str(kwargs.get(\"xtitle\", \"\"))\n\n        # If the request was transformed, the y-axis will be shared under these conditions.\n        if has_params and any(i in params.transform for i in [\"pc1\", \"pch\", \"pca\", \"cch\", \"cca\", \"log\"]):  # type: ignore\n            y1title = \"Log\" if params.transform == \"Log\" else \"Percent\"  # type: ignore\n            y2title = None\n\n        # Set the title for the chart.\n        title: str = \"\"","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/extensions/economy/openbb_economy/economy_views.py#L94-L130","documentation":"The FRED multi-series chart supports at most two y-axis unit scales (left and right axes). When the plotted series carry more than 2 distinct units, the request was NOT transformed via the FRED API, and allow_unsafe is False, the view raises RuntimeError — plotting >2 incompatible scales would be visually meaningless. Normalizing (z-score) or applying a FRED transform puts all series on a comparable scale and bypasses the check.","triggerScenarios":"Charting 3+ FRED series measured in different units (e.g. %, $ billions, index) with no transform parameter and normalize unset; injecting external columns with foreign units.","commonSituations":"Comparing mixed-unit macro series (unemployment rate vs GDP vs M2) on one figure, forgetting normalize=True when building dashboards.","solutions":["Set normalize=True in the charting kwargs to z-score standardize all series onto one scale.","Request the data with a FRED transform (e.g. transform='pch' percent change) so series are unit-free and comparable.","Reduce to series sharing units, or split into multiple charts.","Override knowingly with allow_unsafe=True when you accept a shared axis."],"exampleFix":"# before\nfig = obb.economy.fred.series(['UNRATE','GDP','M2SL'], provider='fred').charting.fred()\n\n# after\nfig = obb.economy.fred.series(['UNRATE','GDP','M2SL'], provider='fred').charting.fred(normalize=True)\n# or on the data request:\nfig = obb.economy.fred.series(['UNRATE','GDP','M2SL'], provider='fred', transform='pch').charting.fred()","handlingStrategy":"validation","validationCode":"units = {meta.get('units') for meta in series_metadata if meta.get('units')}\nif len(units) > 2:\n    # normalize or request a transform before charting\n    kwargs['normalize'] = True","typeGuard":null,"tryCatchPattern":"try:\n    fig = res.charting.fred()\nexcept RuntimeError as e:\n    if 'up to 2 y-axis units' in str(e):\n        fig = res.charting.fred(normalize=True)\n    else:\n        raise","preventionTips":["Set normalize=True whenever mixing more than two unit types.","Use FRED transform='pch'/'pc1' to make series unit-free.","Split mixed-unit dashboards into per-unit figures."],"tags":["charting","fred","units","normalize","multi-series"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}