I create a plot using sns
base on a DafaFrame
.
Now, I would like to add new curve from another dataframe on the plot created previusly.
This is the code of my plot:
tline = sns.lineplot(x='reads', y='time', data=df, hue='method', style='method', markers=True, dashes=False, ax=axs[0, 0])
tline.set_xlabel('Numero di reads')
tline.set_ylabel ('Time [s]')
tline.legend(loc='lower right')
tline.set_yscale('log')
tline.autoscale(enable=True, axis='x')
tline.autoscale(enable=True, axis='y')
Now I have another Dataframe
with the same column of the first DataFrame
. How can I add this new curve with a custom entry in the legend?
This is the structure of the DataFrame
:
Dataset | Method | Reads | Time | Peak-memory |
---|---|---|---|---|
14M | Set | 14000000 | 7.33 | 1035204 |
20K | Set | 200000 | 0.38 | 107464 |
200K | Set | 20000 | 0.07 | 42936 |
2M | Set | 28428648 | 16.09 | 2347740 |
28M | Set | 2000000 | 1.41 | 240240 |
CodePudding user response:
I suggest to use matplotlibs OOP
the important thing is that both lineplots are on the same subplot (ax in this case).