Reputation: 2297
My dataframe looks like this:
Bin A B C Proba-a% Proba-b% Proba-c% gamma%
CPB%
0.100 20841 23195 24546 34.503457 27.103303 22.859837 0.100
0.200 2541 4187 5176 26.517913 13.944499 6.593338 0.200
0.300 2750 1823 1122 17.875550 8.215217 3.067253 0.300
0.400 999 829 448 14.736015 5.609856 1.659334 0.400
0.500 604 495 217 12.837838 4.054181 0.977373 0.500
0.600 436 348 116 11.467630 2.960495 0.612822 0.600
0.700 367 247 76 10.314268 2.184230 0.373979 0.700
0.800 305 186 35 9.355751 1.599673 0.263985 0.800
0.900 280 115 24 8.475801 1.238254 0.188561 0.900
1.000 200 102 18 7.847266 0.917691 0.131992 1.000
what I would like to do is to have on the x axis 'gamma%' and a chart with three lines A, B and C. I saw somewhere that you had to call multiple time plt, I tried that:
plt.plot(x='gamma%', y='A', data=df_b)
plt.plot(x='gamma%', y='B',data=df_b)
plt.plot(x='gamma%', y='C',data=df_b)
But I had the following error:
ValueError: Using arbitrary long args with data is not supported due to ambiguity of arguments.
Use multiple plotting calls instead.
Any idea? Thanks!
Upvotes: 2
Views: 3554
Reputation: 39042
You can also directly use your DataFrame to plot the three columns in a looped manner without having to write three separate plot commands as follows
fig, ax = plt.subplots()
for cols in ['A', 'B', 'C']:
df_b.plot('gamma%', cols, ax=ax)
Upvotes: 0
Reputation: 2122
Actually your method is fine, just dont explicitly say x='gamma%'
. Instead just pass the column name like 'gamma%'
and it should work
Example :
plt.plot('gamma%', 'A', data=df_b)
Here it is directly from the documentation :
Plotting labelled data
There's a convenient way for plotting objects with labelled data (i.e. data that can be accessed by index obj['y']). Instead of giving the data in x and y, you can provide the object in the data parameter and just give the labels for x and y:
plot('xlabel', 'ylabel', data=obj)
Upvotes: 4