Add separate trace based on attribute using plotly Go

Hi there,
i have some GPS satellite data that I am trying to create some plots for that requires the plotting of multiple traces that show the elevation of each satellite (PRN). I can do this quite simply using plotly express, by setting the color attribute to the ‘PRN’ column in my dataframe. However, i would like to do this in Plotly Go, as i have some other datasets that i would like to add to the plot and i’ve built everything using Go rather than px. Anyway, a cut down dataframe (df)looks like this table below

,UTC,Num_sats,PRN,Elevation,Azimuth,SNR
0,09:29:03,18,02,61,114,43
1,09:29:03,18,03,74,235,45
2,09:29:03,18,04,21,173,40
3,09:29:03,18,06,05,290,
4,09:29:03,18,14,10,248,40
5,09:29:03,18,17,49,291,44
6,09:29:03,18,19,27,311,38
7,09:29:03,18,21,43,114,43
8,09:29:03,18,22,19,270,37
9,09:29:03,18,28,11,070,36
10,09:29:03,13,31,02,101,
11,09:29:03,18,32,14,036,41
12,09:29:03,18,49,29,169,40
13,09:29:03,18,36,25,147,40

My code, using plotly express, that works would be:

fig = px.line(df,x=‘UTC’,y=‘Elevation’,color=‘PRN’)

fig.update_traces(mode=‘markers+lines’)

fig.show()

How do i replicate the above using Go? I have tried the following:

fig1 = go.Figure()
fig1.add_traces(go.Scatter(x=df[‘Datetime’], y = df[‘Elevation’], mode = ‘lines’, line=dict(color=df[‘PRN’])))
fig.show()

This does not work. It feels like this should be a relatively straightforward thing to do, but i can’t figure it out.

Many thanks.

I should add that i have looked at the question posted here Setting color based on column in go.Scatter() and while that would work, there are 100+ satellites in orbit at the moment and i’d rather not have to define colours for every single one, as is done in the examples provided in that link

Thanks

ok, i managed to find a solution, so i’ll answer my own question here in case anyone finds it of use.

I needed to loop over each unique value within the PRN attribute. So, my solution is as follows:

fig1 = go.Figure()

for prn in df[‘PRN’].unique():
prndf = df.loc[df[‘PRN’] == prn]
fig1.add_scatter(x=prndf[‘Datetime’],y=prndf[‘Elevation’],name=prn)

fig1.show()

This works as i would like it to