Reputation: 1645
I have a pandas dataframe, and I want to plot for each column a line, from the origin to the point (a,b)
df = pd.DataFrame(data=[[1,2], [7,3]], columns=['a', 'b'])
df.head(10)
df.plot(kind='line')
But I want 2 lines, one from (0,0) to (1,2) and the second from (0,0) to (7,3).
Upvotes: 1
Views: 1873
Reputation: 586
Something like this:
import matplotlib.pylab as pl
for i in range(0, 2):
pl.plot([0, df.iloc[i][0]], [0,df.iloc[i][1]], label=(i+1))
pl.legend(loc='upper left')
pl.show()
It's not elegant but it works.
Upvotes: 2