OpenBB-finance/OpenBB · warning · OpenBBError
No data to plot.
Error message
No data to plot.
What it means
Simple emptiness check in the maritime chokepoint chart view: before building the DataFrame, it requires a non-empty input list. Empty input means there is nothing to map or tabulate, and plotting would produce a broken figure, so it fails fast. Note data=None would raise TypeError at len() rather than this error.
Source
Thrown at openbb_platform/providers/imf/openbb_imf/views/maritime_chokepoint_info.py:34
from openbb_charting.core.openbb_figure import OpenBBFigure
from plotly import graph_objects as go
from plotly.subplots import make_subplots
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, ImfMaritimeChokePointInfoData) for item in data)
):
raise OpenBBError(
"Invalid data format. Expected a list of ImfMaritimeChokePointInfoData."
)
if len(data) == 0:
raise OpenBBError("No data to plot.")
df = DataFrame([item.model_dump() for item in data])
if theme == "dark":
geo_bgcolor = "rgba(0,0,0,0)"
landcolor = "#3a5d3a"
countrycolor = "#cccccc"
oceancolor = "#223355"
coastlinecolor = "#cccccc"
lakecolor = "#0d47a1"
rivercolor = "#0d47a1"
table_header_fill = "#222e3c"
table_header_font = "#fff"
table_cell_fill = ["#232323", "#181818"] * (len(df) // 2 + 1)
font_color = "#fff"
annotation_color = "#aaa"
plot_bgcolor = "rgba(21,21,21,1)"
paper_bgcolor = "rgba(21,21,21,1)"
else:View on GitHub (pinned to 3e071fcc2c)
Solutions
- Check the fetch result is non-empty before invoking the chart view.
- Broaden or correct query filters (dates, chokepoint selection) so the fetch returns rows.
- Handle upstream EmptyDataError explicitly rather than coercing to an empty list.
Example fix
# before
result = obb.economy.imf.maritime_chokepoint(...).results
plot_maritime_chokepoint_info(result) # may raise 'No data to plot.'
# after
if not result:
print('No chokepoint data for the given filters')
else:
plot_maritime_chokepoint_info(result) Defensive patterns
Strategy: validation
Validate before calling
if not data:
raise SystemExit('No maritime chokepoint data for the given filters')
plot_maritime_chokepoint_info(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_maritime_chokepoint_info(data)
except OpenBBError as e:
if str(e) == 'No data to plot.':
show_empty_state() # expected when filters match nothing
else:
raise Prevention
- Check fetch results for emptiness before charting
- Broaden date/chokepoint filters when empty
- Handle upstream EmptyDataError explicitly rather than coercing to []
When it happens
Trigger: Calling plot_maritime_chokepoint_info([]) - typically because the upstream fetch returned no rows (e.g. a date filter with no matching chokepoint observations) and the caller forwarded the empty result straight to the chart view.
Common situations: Date ranges outside available data; filters (country/chokepoint) matching nothing; upstream EmptyDataError being swallowed and replaced with an empty list before plotting.
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/5f84f18cd88958b7.
Report an issue: GitHub.