✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🐇 Announcing Dash VTK for 3d simulation graphics. Check out the March webinar.

Problems with rendering charts from plotly on a loop, and displaying them in vs code

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()   

#######
plotly.version
‘4.8.1’