OpenBB-finance/OpenBB · error · RuntimeError

This method supports up to 2 y-axis units. Please use the 't

Error message

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`.

What it means

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.

Source

Thrown at openbb_platform/extensions/economy/openbb_economy/economy_views.py:112

        # Get a unique list of all units of measurement in the DataFrame.
        y_units = list({metadata.get(col).get("units") for col in columns if col in metadata})  # type: ignore
        if has_params is True and not y_units:
            y_units = [ytitle_dict.get(params.transform)]  # type: ignore

        if normalize or (
            kwargs.get("bar") is True
            and len(y_units) > 1
            and (
                has_params is False
                or not any(i in params.transform for i in ["pc1", "pch", "pca", "cch", "cca", "log"])  # type: ignore
            )
        ):
            normalize = True
            df_ta = df_ta.apply(z_score_standardization)

        if len(y_units) > 2 and has_params is False and allow_unsafe is False:
            raise RuntimeError(
                "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`."
            )

        y1_units = y_units[0] if y_units else None
        y1title = y1_units
        y2title = y_units[1] if len(y_units) > 1 else None
        xtitle = str(kwargs.get("xtitle", ""))

        # If the request was transformed, the y-axis will be shared under these conditions.
        if has_params and any(i in params.transform for i in ["pc1", "pch", "pca", "cch", "cca", "log"]):  # type: ignore
            y1title = "Log" if params.transform == "Log" else "Percent"  # type: ignore
            y2title = None

        # Set the title for the chart.
        title: str = ""

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Set normalize=True in the charting kwargs to z-score standardize all series onto one scale.
  2. Request the data with a FRED transform (e.g. transform='pch' percent change) so series are unit-free and comparable.
  3. Reduce to series sharing units, or split into multiple charts.
  4. Override knowingly with allow_unsafe=True when you accept a shared axis.

Example fix

# before
fig = obb.economy.fred.series(['UNRATE','GDP','M2SL'], provider='fred').charting.fred()

# after
fig = obb.economy.fred.series(['UNRATE','GDP','M2SL'], provider='fred').charting.fred(normalize=True)
# or on the data request:
fig = obb.economy.fred.series(['UNRATE','GDP','M2SL'], provider='fred', transform='pch').charting.fred()
Defensive patterns

Strategy: validation

Validate before calling

units = {meta.get('units') for meta in series_metadata if meta.get('units')}
if len(units) > 2:
    # normalize or request a transform before charting
    kwargs['normalize'] = True

Try / catch

try:
    fig = res.charting.fred()
except RuntimeError as e:
    if 'up to 2 y-axis units' in str(e):
        fig = res.charting.fred(normalize=True)
    else:
        raise

Prevention

When it happens

Trigger: 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.

Common situations: Comparing mixed-unit macro series (unemployment rate vs GDP vs M2) on one figure, forgetting normalize=True when building dashboards.

Related errors


AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14). Data as JSON: /api/errors/53efd2c7acbc3be0. Report an issue: GitHub.