I'm new to Streamlit and trying to plot a graph with the widget st.line_chart.
I have a dictionary that I filled with data from different files with :
listFilesTemp = glob.glob(folder+ '/*.npy')
nbFilesTemp = len(listFilesTemp)
TempDict = {}
for j in range(len(listFilesTemp)):
dataExtract = np.load(listFilesTemp[j])
filename = listFilesTemp[j].replace(folderTemp + '\\', '')
TempDict[filename] = dataExtract
So I now have a dictionary composed of string keys and for each an array of values.
I would like to plot data from several files on 1 interactive graph, but I must be missing something from the documentation, I don't manage to succeed. I tried :
for i in TempDict:
st.line_chart(data=TempDict[i], x=None, y=None)
But it displays 1 graph/file. It seems that I have to modify the x or y parameters of this function, I tried a couple of things but I have not managed to do so far. How can I say to streamlit to plot several arrays from my dict in one graph?
I suggest you use plotly in combination with st.plotly_chart().
The following code uses plotly express library, adapt it to your dictionary:
st.plotly_chart(px.line(TempDict, x="<Xvar>" ,y=["yvar1","yvar2","yvarX"]), use_container_width=True)