Simple line plots using seaborn

前端 未结 3 1618
渐次进展
渐次进展 2021-01-31 13:59

I\'m trying to plot a ROC curve using seaborn (python). With matplotlib I simply use the function plot:

plt.plot(one_minus_specificity, sensitivity,         


        
3条回答
  •  感情败类
    2021-01-31 14:13

    It's possible to get this done using seaborn.lineplot() but it involves some additional work of converting numpy arrays to pandas dataframe. Here's a complete example:

    # imports
    import seaborn as sns
    import numpy as np
    import pandas as pd
    
    # inputs
    In [41]: num = np.array([1, 2, 3, 4, 5])
    In [42]: sqr = np.array([1, 4, 9, 16, 25])
    
    # convert to pandas dataframe
    In [43]: d = {'num': num, 'sqr': sqr}
    In [44]: pdnumsqr = pd.DataFrame(d)
    
    # plot using lineplot
    In [45]: sns.set(style='darkgrid')
    In [46]: sns.lineplot(x='num', y='sqr', data=pdnumsqr)
    Out[46]: 
    

    And we get the following plot:

提交回复
热议问题