2

I have a dataframe like the following:

In [0]: df.head()
Out[0]:

    airfield   airplane_cabin   airport_terminal   alcove
0       0.0            0.00              0.00     0.0
1       0.0            0.00              0.01     0.0
2       0.02           0.00              0.00     0.03
3       0.0            0.00              0.00     0.0
4       0.0            0.01              0.00     0.0

, where each row is a frame of a video containing the probabilities for each of the classes (I have more than 4 classes in real problem and that is why they are so low here). What I would like would be to print a lineplot where I can have the four frames on the X-axis and all the unique probabilities on the Y-axis. Then I would like to have different lines for each of the four classes. Something like in the following picture:

example

, where "signal" would be all the different unique probabilities; "timepoint" would be the frame number; and "event" would be the different classes, being "stim" and "cue" what "airfield" and "airplane_cabin" are in our example.

I hope the question is clear and thank you a lot for your help in advance!

Best,

  • 1
    Use [pandas melt](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.melt.html) to transform the data frame in a long format i.e. create one column for variable names and one column for values. Also check how to make a [reproducible example](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples). – Paul Rougieux Sep 04 '20 at 11:29

1 Answers1

1

Wouldn't it just be:

sns.lineplot(data=df)
plt.xlabel('frame number')
plt.ylabel('probability')

Output:

fig

perl
  • 9,826
  • 1
  • 10
  • 22