# -*- coding:utf-8 -*-
from matplotlib import pyplot
from scipy.optimize import curve_fit
import numpy as np
# 折线图
def func(x,a,b):
    return a*np.exp(b/x)

def linePlaut(list):

    x_axis = [0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100]
    data = [10,20,30,40,50,60,70,80,90,100]
    # data = [x for x in data]
    print(len(x_axis))
    # y1_axis=sorted(y1_axis)
  #  router_axis=[0.84,0.86,0.87,0.87,0.88,0.93,0.95,0.94,0.93,0.94,0.93,0.94,0.946,0.94,0.94,0.93,0.955,0.94,0.94,0.94,0.95,0.95,0.95]
  #  print_axis= [0.63,0.74,0.79,0.83,0.89,0.94,0.97,0.97,0.97,0.98,0.98,0.98,0.98,0.98,0.98,0.99,0.99 ,0.99,0.99,0.99,0.99,0.99,0.99]
  #  camera_axis=[0.53,0.73,0.84,0.86,0.88,0.89,0.91,0.93,0.95,0.95,0.96,0.95,0.948,0.96,0.96,0.96,0.96,0.96,0.96,0.96,0.96,0.96,0.96]
    router_axis = [y for y in list]
 #   print_axis = [y for y in list]
 #   camera_axis = [y for y in list]
    print(len(router_axis))
    pyplot.figure()
    ylable=[y for y in range (0,55,10)]
    pyplot.ylim([0,50])
    pyplot.yticks(ylable,fontsize=13)
    pyplot.xticks(data,fontsize=13)

    legends = { 'F1 Scores ': '-v-'}
    pyplot.legend(legends.keys(), loc=4,fontsize=13)
    pyplot.ylabel('number of file degree(%)',fontsize=13)
    pyplot.xlabel('Similarity degree(%)',fontsize=13)
    pyplot.grid(ls=':')
    '''###############拟合曲线camera==============
    popt, pcov = curve_fit(func, x_axis, camera_axis)
    a = popt[0]  # popt里面是拟合系数，读者可以自己help其用法
    b = popt[1]
    yvals = func(x_axis, a, b)
    pyplot.plot(x_axis, camera_axis, 'v', color='red',label='camera')
    pyplot.plot(x_axis, yvals, 'red')
    ##################拟合曲线camera==============

    ##################拟合曲线print==============
    popt, pcov = curve_fit(func, x_axis, print_axis)
    a = popt[0]  # popt里面是拟合系数，读者可以自己help其用法
    b = popt[1]
    yvals = func(x_axis, a, b)
    pyplot.plot(x_axis, print_axis, 'o', color='blue',label='printer')
    pyplot.plot(x_axis, yvals, 'blue')
    ##################拟合曲线print=============='''

    ##################拟合曲线router==============
    popt, pcov = curve_fit(func, x_axis, router_axis)
    a = popt[0]  # popt里面是拟合系数，读者可以自己help其用法
    b = popt[1]
    yvals = func(x_axis, a, b)
    pyplot.plot(x_axis, router_axis, '*', color='red',label='router')
 #   pyplot.plot(x_axis, yvals, 'red')
    ##################拟合曲线router==============


    # pyplot.plot(x_axis, camera_axis, ':v', color='red')
    # pyplot.plot(x_axis, print_axis, ':o', color='blue')
    # pyplot.plot(x_axis, router_axis, ':*', color='gray')
 #   pyplot.legend(['original camera','curve camera' ,'original printer','curve printer', 'original router','curve router'], loc=4, fontsize=10)
    pyplot.show()