I use this simple scrip on every graph I made, and I get a simple message.
fig_none = go.Figure()
fig_none.add_trace(go.Scatter(
x=[0, 1, 2, 3, 4, 5, 6, 7, 8, 10],
y=[0, 4, 5, 1, 2, 3, 2, 4, 2, 1],
mode="lines+markers+text",
text=["","","","", "SIN DATOS", "","","", "", ''],
textfont_size=40,
))
fig_none.update_layout(
paper_bgcolor=background,
plot_bgcolor=background
)
fig_none.update_layout(
xaxis = dict(
showgrid=False,
gridcolor=background,
zerolinecolor=background),
yaxis = dict(
showgrid=False,
gridcolor=background,
zerolinecolor=background))
try:
read_cube_orig = pd.read_csv(make_cube,
sep=',',
header=None,
usecols=[0,1,2,3],
names=['X', 'Y', 'Z','DATA']
)
read_cube = read_cube_orig #.round(0)
except FileNotFoundError:
return fig_none
You can try to adapt this script to your graph. What I do is:
- I try to read the data, but if I get the ‘‘FileNotFoundError’’ (or any error you have), I plot the fig_none graph.