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

Text (label of plot) from dictonary

Hi I have a dictonary which looks likes below.

dict = {‘time_0’:[0,1,2,…,1047], ‘time_1’:[0,1,2…,1047], ‘time_2’:[0,1,2…,1047}

I want my text or label of plot to use this dictonary.

for example. plot 1018: text= ‘time_0:1018, time_1:1018, time_2:1018’

how to iteratively to this. dictonaries inside dict are created dynamically and can increase or decrease.

Hi @ankush.nagaraju,

I don’t think I understand what kind of plot you would like to make. If you’re asking how to build the text string above from the dict above you could use something like

i = 1018
d = {'time_0':[0,1,2,1047], 'time_1':[0,1,2,1047], 'time_2':[0,1,2,1047]}

labels = ['{k}:{i}'.format(k=k, i=i) for k in d]
['time_0:1018', 'time_1:1018', 'time_2:1018']
labels_str = ', '.join(labels)
'time_0:1018, time_1:1018, time_2:1018'