0

I try to plot multi-line with different attribute(color, line-type, etc) with pandas grouby data set. My code plots all blue line of multiple source. How to apply line attribute at each group?

My code is bleow.

from pandas import Series, DataFrame
import pandas as pd
import matplotlib.pyplot as plt

xls_file = pd.ExcelFile(r'E:\SAT_DATA.xlsx')
glider_data = xls_file.parse('Yosup (4)', parse_dates=[0])
each_glider = glider_data.groupby('Vehicle') 

fig, ax = plt.subplots(1,1); 
glider_data.groupby("Vehicle").plot(x="TimeStamp", y="Temperature(degC)", ax=ax)
plt.legend(glider_data['Vehicle'], loc='best')
plt.xlabel("Time")
plt.ylabel("Temp")
plt.show()
Yosup Park
  • 39
  • 4
  • possible duplicate of [Plotting results of Pandas GroupBy](http://stackoverflow.com/questions/15465645/plotting-results-of-pandas-groupby) – LondonRob Jul 07 '15 at 14:37

1 Answers1

0

I think you need to loop over the groups from groupby. Something like:

for i,group in glider_data.groupby('Vehicle'):
    group.plot(x='TimeStamp', y='Temperature(degC)', ax=ax, label=i)
tmdavison
  • 64,360
  • 12
  • 187
  • 165
  • Thank you tom, But your suggestion bring same result without label option. label option generated parsing error. – Yosup Park Jul 08 '15 at 03:11