Hi Iām having problems with rendering charts from plotly on a loop, and displaying them in vs code.
Iām very new to thisā¦but after many hours (instead of minutes) Iāve managed to make the loop (to my logic) run āfineā
when it runs, āit seems to do its jobā ā¦It renders the desired collection of charts on a cellā¦
However, if I run the loop again, (say) iterating over a different list, the loop also seems to runs fineā¦
except that all the chart output in the previous cell ( the one that was just OK before)⦠crashes and shows a blank figure with a stupid sad face on it.
I have a loop like this
%%
my_label ='pass my label'
my_x= 'pass my x axis'
my_measure = ' pass my measure'
my_color = 'something to color by'
my_data ='my pandas df'
my_list_loop= 'my list'
for my_measure in my_list_loop:
locals()["fig_" + my_measure]=px.line(my_data,x=my_x,
y=my_measure,
)
locals()["fig_" + my_measure].update_layout(
title=('bla'),
)
)
locals()["fig_" + my_measure].show()
Hi there, I have been finding an issue when defining a function in an external python file that takes in some data and performs multiple plots in a loop. IE I pass a list of dataframes into the function and then make specific plots from those dataframes. The exact same plots generated within the vs code notebook without using loops works fine, but inside loops the new plots generate but the old ones end up getting āsoft deletedā. All the data traces dissapear and sometimes even the axes. If you hover the mouse over the graphs you can still see data tool tips and if there is a legend clicking the trace to hide it and then again to show it sometimes restores the graph but sometimes that does not work. Hope this helps.
Hi.
I am having a very similar issue.
This is the kind of loop I am running. Some plots are showing up fine, and some others with invisible scatter dots.
for iFile in range(len(filename2)):
file = filename2[iFile]
with open(file,"rb") as f:
np_data= np.loadtxt(filter(lambda x:b"\xe2\x88\x9e" not in x,f), delimiter= "\t", skiprows=12, max_rows= 1024)
list_data2.append(list(np_data.copy()))
fig = px.scatter(x=np.arange(1,1025,1), y=list_data2[iFile])
fig.show()