Reputation:
I have a data set with Time
, Name
, and Values
. I want to plot Time
in the x-axis, and Values
in the y-axis, but indexed by Name
.
So far I did the following:
Simplified dataset:
Time Node Value
0 0 0 64
1 0 1 54
2 0 2 80
3 0 3 50
4 10 0 62
5 10 1 53
6 10 2 76
7 10 3 47
Code:
df = df[['Time','Node','Value']]
df.plot(x='Time', y='Value')
plt.show()
How do I include Node
as indexes to the values, so I have one line per node/value?
Upvotes: 0
Views: 61
Reputation: 999
The axis/columns now represent the data in a more informative way
df.set_index(['Time', 'Node']).unstack().plot()
Pay attention to the column and row headings
df.set_index(['Time', 'Node']).unstack()
Out[]:
Value
Node 0 1 2 3
Time
0 64 54 80 50
10 62 53 76 47
Upvotes: 1
Reputation: 570
I'm not sure I have understood your question but you can try that:
import seaborn as sns
myPlot = sns.lmplot('Time', 'Value', data=df , hue='Node', size = 10, fit_reg=False)
plt.show()
Upvotes: 1