OpenBB-finance/OpenBB · warning · OpenBBError
No data to plot.
Error message
No data to plot.
What it means
Emptiness check in the port-info map view: the chart cannot be built from an empty input list, so it raises before constructing the DataFrame (which would additionally be filtered by vessel_count_total > 0). It signals the caller passed zero rows, usually an upstream fetch that matched nothing.
Source
Thrown at openbb_platform/providers/imf/openbb_imf/views/port_info.py:29
from pandas import DataFrame
try:
import plotly.express as px
from openbb_charting.core.openbb_figure import OpenBBFigure
except Exception as e:
raise OpenBBError(
"Could not import Charting modules. Install with `pip install openbb-charting`."
+ f" -> {e}"
) from e
if (
data is not None
and not isinstance(data, list)
or not all(isinstance(item, ImfPortInfoData) for item in data)
):
raise OpenBBError("Invalid data format. Expected a list of ImfPortInfoData.")
if len(data) == 0:
raise OpenBBError("No data to plot.")
df = DataFrame([item.model_dump() for item in data]).query("vessel_count_total > 0")
min_size, max_size = 4, 10
if "country" in df.columns and df["country"].nunique() == 1:
share_import = df["share_country_maritime_import"].fillna(0)
share_export = df["share_country_maritime_export"].fillna(0)
df["import_export_share"] = share_import + share_export
share_values = df["import_export_share"]
if share_values.nunique() > 1:
df["marker_size"] = (
(share_values - share_values.min())
/ (share_values.max() - share_values.min() + 1e-9)
) * (max_size - min_size) + min_size
else:
df["marker_size"] = (min_size + max_size) / 2View on GitHub (pinned to 3e071fcc2c)
Solutions
- Verify the fetch call's filters and retry the data fetch before plotting.
- Handle EmptyDataError from the data endpoint instead of forwarding an empty list to the view.
- If all rows have vessel_count_total == 0, expect an empty figure - filter or message accordingly in your UI.
Example fix
# before
results = obb.economy.imf.port_info(country='XX', chart=True)
# after
res = obb.economy.imf.port_info(country='XX')
if not res.results:
raise SystemExit(f'No ports found for {res.provider} - adjust filters')
chart = res.charting.to_chart() Defensive patterns
Strategy: validation
Validate before calling
if not data:
print('No port data for the given filters')
else:
plot_port_info_map(data) Type guard
def has_rows(data: list | None) -> bool:
return bool(data) Try / catch
from openbb_core.app.model.abstract.error import OpenBBError
try:
plot_port_info_map(data)
except OpenBBError as e:
if str(e) == 'No data to plot.':
show_empty_state()
else:
raise Prevention
- Guard emptiness before charting
- Also handle the vessel_count_total>0 post-filter case (empty map, not error)
- Catch upstream EmptyDataError instead of forwarding []
When it happens
Trigger: Calling plot_port_info_map([]) after a port-info fetch returned no records - e.g. a country filter with no ports, or a period with no vessel observations. Note that even non-empty input whose rows all have vessel_count_total == 0 yields an empty DataFrame after .query(...), producing an empty map rather than this error.
Common situations: Filters (country, date) excluding all ports; API downtime upstream causing empty results that a wrapper converted to []; pagination bugs returning zero pages.
Related errors
- No data to plot.
- Invalid data format. Expected a list of ImfMaritimeChokePoin
- Invalid data format. Expected a list of ImfPortInfoData.
- OBBject Extension Error -> An OBBject extension that acts
- Error: No data to plot.
AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14).
Data as JSON: /api/errors/0b3fbf2db5f8624b.
Report an issue: GitHub.