import numpy as np
import pandas as pd
from pyecharts.charts import Line
from pyecharts import options as opts
from matplotlib import pyplot as plt
import xlrd
# 读取 csv 文件
data = pd.read_excel('F:/LJX/lc8.xls')
# 假设 csv 文件中有两列数据:'x' 和 'y'
x_values = data['Temperature']
y_values = data['Abs']
plt.rcParams['font.sans-serif'] = ['SimHei'] # 用来正常显示中文标签
plt.rcParams['axes.unicode_minus'] = False # 用来正常显示负号
plt.plot(x_values, y_values)
plt.xlabel("Temperature",size=14)
plt.ylabel("Abs",size=14)
plt.title("R8折线图",fontdict=None,loc="left",pad=None)
dy_dx = abs(np.diff(y_values) / np.diff(x_values))
print(type(dy_dx))
dy_dx_list = dy_dx.tolist()
print(type(dy_dx_list))
max_dao = dy_dx_list.index(max(dy_dx_list))
print(max_dao)
textprint = '导数最大值:' + str(dy_dx_list[max_dao]) +'。温度为:'+str(x_values[max_dao])
plt.annotate(textprint, xy=(x_values[max_dao],y_values[max_dao]), xytext=(x_values[max_dao],y_values[max_dao]-0.010), arrowprops=dict(arrowstyle="->"))
plt.show()
# # 创建折线图对象
# line_chart = Line()
#
# # 添加数据
# line_chart.add_xaxis(x_values.tolist())
# line_chart.add_yaxis('折线', y_values.tolist())
#
# # 设置全局配置
# line_chart.set_global_opts(
# title_opts=opts.TitleOpts(title="black折线图"),
# xaxis_opts=opts.AxisOpts(name='Temperature'),
# yaxis_opts=opts.AxisOpts(name='Abs')
# )
#
# # 渲染生成 HTML 文件
# line_chart.render('black.html')
数据如下:绘图也如下:
L8-1%MeOH 85.00-10.00 Ramp 2 | |
Temperature | Abs |
84.97000122 | 0.289775699 |
84.73000336 | 0.289772898 |
84.51999664 | 0.289753914 |
84.30999756 | 0.289791703 |
84.12000275 | 0.289888173 |
83.91999817 | 0.289871931 |
83.72000122 | 0.289892614 |
83.51999664 | 0.289982051 |
83.31999969 | 0.289918751 |
83.12000275 | 0.289979219 |
82.91999817 | 0.290063828 |
82.72000122 | 0.290138334 |
82.51999664 | 0.290162265 |
82.31999969 | 0.290249765 |
82.12000275 | 0.290316135 |
81.91999817 | 0.290309072 |
81.72000122 | 0.290509135 |
81.51999664 | 0.290560335 |
81.31999969 | 0.290631235 |
81.12000275 | 0.290638924 |
80.91999817 | 0.290659249 |
80.76999664 | 0.290761203 |
80.51999664 | 0.290816337 |
80.31999969 | 0.290902913 |
80.12000275 | 0.290874779 |
79.91999817 | 0.291025519 |
79.72000122 | 0.291229129 |
79.54000092 | 0.291381031 |
79.31999969 | 0.291313767 |
79.12000275 | 0.291418821 |
78.91999817 | 0.291318715 |
78.76999664 | 0.291283578 |
78.47000122 | 0.291214496 |
78.31999969 | 0.291229159 |
78.12000275 | 0.291251034 |
77.91000366 | 0.291236848 |
77.72000122 | 0.291296125 |
77.51999664 | 0.291178763 |
77.31999969 | 0.291171879 |
77.12000275 | 0.291263372 |
76.91999817 | 0.291264534 |
76.73000336 | 0.291292548 |
76.51999664 | 0.291220725 |
76.31999969 | 0.291292846 |
76.13999939 | 0.291277051 |
75.91999817 | 0.291291118 |
75.72000122 | 0.29129523 |
75.54000092 | 0.291274279 |
75.37000275 | 0.29128772 |
75.12000275 | 0.291312903 |
74.94000244 | 0.291347712 |
74.76999664 | 0.29123205 |
74.51999664 | 0.291254818 |
74.31999969 | 0.291262716 |
74.12000275 | 0.291325003 |
73.91999817 | 0.291266918 |
73.72000122 | 0.291336954 |
73.51999664 | 0.29133147 |
73.31999969 | 0.291346252 |
73.16999817 | 0.291326523 |
72.91999817 | 0.291337758 |
72.72000122 | 0.291334778 |
72.51999664 | 0.291236609 |
72.31999969 | 0.291340023 |
72.12000275 | 0.291321546 |
71.91999817 | 0.291348487 |
71.76999664 | 0.291358143 |
71.51999664 | 0.291290313 |
71.37000275 | 0.291313708 |
71.12000275 | 0.291264296 |
70.91999817 | 0.291350961 |
70.72000122 | 0.29136616 |
70.51999664 | 0.291316688 |
70.31999969 | 0.29128924 |
70.12000275 | 0.291255236 |
69.91999817 | 0.291306883 |
69.72000122 | 0.291192532 |
69.51999664 | 0.291173846 |
69.31999969 | 0.291179359 |
69.12000275 | 0.291233063 |
68.97000122 | 0.291287482 |
68.72000122 | 0.291226387 |
68.51999664 | 0.291262358 |
68.31999969 | 0.29126206 |
68.16999817 | 0.291240603 |
67.91999817 | 0.291168541 |
67.76999664 | 0.291122228 |
67.54000092 | 0.291165233 |
67.37000275 | 0.291113824 |
67.12000275 | 0.291047186 |
66.91999817 | 0.29107511 |
66.72000122 | 0.291123986 |
66.51999664 | 0.291230887 |
66.31999969 | 0.291136354 |
66.12000275 | 0.291114628 |
65.91999817 | 0.291155487 |
65.72000122 | 0.291145295 |
65.51999664 | 0.291066349 |
65.37000275 | 0.291025281 |
65.12000275 | 0.290942103 |
64.91999817 | 0.291067541 |
64.72000122 | 0.291023403 |
64.51999664 | 0.291036457 |
64.31999969 | 0.290963501 |
64.12000275 | 0.290956467 |
63.91999817 | 0.290989757 |
63.72000122 | 0.290984869 |
63.52000046 | 0.290999979 |
63.34000015 | 0.290966332 |
63.11999893 | 0.290926278 |
62.91999817 | 0.29093352 |
62.72000122 | 0.290865094 |
62.52000046 | 0.290893644 |
62.31999969 | 0.290822715 |
62.16999817 | 0.290895939 |
61.91999817 | 0.290778458 |
61.74000168 | 0.290800095 |
61.52000046 | 0.290780872 |
61.31999969 | 0.29076016 |
61.11999893 | 0.290794849 |
60.91999817 | 0.290686935 |
60.72000122 | 0.290691435 |
60.52000046 | 0.290566146 |
60.36999893 | 0.290671319 |
60.11999893 | 0.290581554 |
59.91999817 | 0.29061988 |
59.72000122 | 0.290570319 |
59.52000046 | 0.290494889 |
59.31999969 | 0.29041636 |
59.11999893 | 0.290560424 |
58.91999817 | 0.290550739 |
58.72000122 | 0.29045558 |
58.54000092 | 0.290323019 |
58.31999969 | 0.290423036 |
58.11999893 | 0.290393472 |
57.93999863 | 0.290405154 |
57.72000122 | 0.290409893 |
57.52000046 | 0.290291041 |
57.31999969 | 0.2904208 |
57.11999893 | 0.290308923 |
56.91999817 | 0.290231735 |
56.74000168 | 0.290227145 |
56.56999969 | 0.290249825 |
56.33000183 | 0.290192008 |
56.16999817 | 0.29016766 |
55.91999817 | 0.290216953 |
55.72999954 | 0.290187359 |
55.52000046 | 0.290102571 |
55.31999969 | 0.290104598 |
55.15000153 | 0.290063471 |
54.91999817 | 0.289918304 |
54.72000122 | 0.289920121 |
54.52000046 | 0.289979011 |
54.36999893 | 0.289980888 |
54.11999893 | 0.289954096 |
53.91999817 | 0.28988874 |
53.72000122 | 0.28974846 |
53.52000046 | 0.289820552 |
53.31999969 | 0.289742619 |
53.11999893 | 0.289817274 |
52.93999863 | 0.28978923 |
52.72000122 | 0.289813191 |
52.52000046 | 0.289613396 |
52.31999969 | 0.289732784 |
52.16999817 | 0.289775223 |
51.91999817 | 0.289646894 |
51.77000046 | 0.289596826 |
51.52000046 | 0.28956914 |
51.31999969 | 0.289584905 |
51.11999893 | 0.289490074 |
50.91999817 | 0.289438248 |
50.72000122 | 0.289477974 |
50.52000046 | 0.289325744 |
50.31999969 | 0.289276809 |
50.11999893 | 0.289331555 |
49.91999817 | 0.289295018 |
49.72000122 | 0.289296627 |
49.52000046 | 0.28915143 |
49.31999969 | 0.289193183 |
49.11999893 | 0.289128959 |
48.91999817 | 0.289065033 |
48.72000122 | 0.289002121 |
48.52000046 | 0.289101541 |
48.31999969 | 0.289002627 |
48.11999893 | 0.28890878 |
47.91999817 | 0.289007485 |
47.72000122 | 0.288935453 |
47.52000046 | 0.288857132 |
47.27000046 | 0.288808048 |
47.11999893 | 0.288675219 |
46.91999817 | 0.288865328 |
46.72000122 | 0.288711906 |
46.52000046 | 0.288633972 |
46.31999969 | 0.28860575 |
46.15000153 | 0.28852132 |
45.91999817 | 0.288538575 |
45.66999817 | 0.288431108 |
45.52999878 | 0.288401216 |
45.31999969 | 0.288309574 |
45.11999893 | 0.288317353 |
44.91999817 | 0.288279504 |
44.72000122 | 0.288180709 |
44.54999924 | 0.288055897 |
44.31999969 | 0.288086653 |
44.11999893 | 0.28794685 |
43.91999817 | 0.287966996 |
43.72000122 | 0.287874937 |
43.52000046 | 0.287852168 |
43.36999893 | 0.287828118 |
43.11999893 | 0.287792981 |
42.91999817 | 0.287585467 |
42.72999954 | 0.287576437 |
42.52000046 | 0.287577331 |
42.31999969 | 0.287411392 |
42.11999893 | 0.28738001 |
41.91999817 | 0.287313342 |
41.72000122 | 0.287242383 |
41.54000092 | 0.287164331 |
41.31999969 | 0.287036091 |
41.11999893 | 0.28703624 |
40.91999817 | 0.286783516 |
40.77000046 | 0.286710471 |
40.52000046 | 0.286570787 |
40.31999969 | 0.28652817 |
40.11999893 | 0.286334992 |
39.91999817 | 0.286312372 |
39.72000122 | 0.286121011 |
39.52999878 | 0.286084503 |
39.31999969 | 0.285883009 |
39.11999893 | 0.285734564 |
38.91999817 | 0.285749257 |
38.72000122 | 0.285529494 |
38.56999969 | 0.28531602 |
38.31999969 | 0.285131425 |
38.11999893 | 0.284954608 |
37.91999817 | 0.284751147 |
37.72000122 | 0.284648031 |
37.52999878 | 0.284379751 |
37.31999969 | 0.284210891 |
37.11999893 | 0.284112632 |
36.91999817 | 0.283857942 |
36.72000122 | 0.283601731 |
36.54000092 | 0.283411682 |
36.31999969 | 0.283199817 |
36.11999893 | 0.282873571 |
35.86999893 | 0.282679051 |
35.72000122 | 0.282400459 |
35.52000046 | 0.282109261 |
35.31999969 | 0.281829298 |
35.11999893 | 0.281520426 |
34.91999817 | 0.281252295 |
34.72000122 | 0.280893564 |
34.52999878 | 0.280569941 |
34.31999969 | 0.280233234 |
34.11999893 | 0.27978155 |
33.91999817 | 0.27933985 |
33.72000122 | 0.278997123 |
33.52000046 | 0.27866739 |
33.36999893 | 0.278179318 |
33.11999893 | 0.277876556 |
32.91999817 | 0.277383536 |
32.72000122 | 0.277005196 |
32.52000046 | 0.276473284 |
32.31999969 | 0.276106566 |
32.11999893 | 0.275604546 |
31.92000008 | 0.275117368 |
31.71999931 | 0.274595618 |
31.52000046 | 0.274127632 |
31.34000015 | 0.273532987 |
31.12000084 | 0.272938997 |
30.92000008 | 0.2725676 |
30.71999931 | 0.271897912 |
30.52000046 | 0.271363765 |
30.31999969 | 0.270751566 |
30.12000084 | 0.270129323 |
29.92000008 | 0.269645751 |
29.71999931 | 0.269051194 |
29.52000046 | 0.268456399 |
29.31999969 | 0.267962068 |
29.12000084 | 0.267270446 |
28.92000008 | 0.266738862 |
28.71999931 | 0.266006351 |
28.52000046 | 0.265481979 |
28.31999969 | 0.264831275 |
28.12000084 | 0.264232904 |
27.92000008 | 0.263675451 |
27.71999931 | 0.26303494 |
27.52000046 | 0.262438268 |
27.31999969 | 0.261804164 |
27.12000084 | 0.261120498 |
26.92000008 | 0.260569006 |
26.71999931 | 0.260044336 |
26.52000046 | 0.259405434 |
26.31999969 | 0.258819312 |
26.12000084 | 0.258242279 |
25.92000008 | 0.257679939 |
25.71999931 | 0.2570979 |
25.52000046 | 0.256487757 |
25.37000084 | 0.25590229 |
25.12000084 | 0.25532794 |
24.92000008 | 0.254778177 |
24.71999931 | 0.25410524 |
24.52000046 | 0.253657639 |
24.31999969 | 0.253173351 |
24.12000084 | 0.252608061 |
23.94000053 | 0.252033025 |
23.71999931 | 0.251483679 |
23.52000046 | 0.250937939 |
23.34000015 | 0.250526547 |
23.12000084 | 0.249979004 |
22.92000008 | 0.249466568 |
22.73999977 | 0.249063507 |
22.52000046 | 0.248660624 |
22.31999969 | 0.248175144 |
22.12000084 | 0.247794017 |
21.92000008 | 0.247374252 |
21.75 | 0.246980786 |
21.56999969 | 0.246683523 |
21.31999969 | 0.24631466 |
21.12000084 | 0.245911688 |
20.92000008 | 0.245679408 |
20.71999931 | 0.245338857 |
20.52000046 | 0.244930774 |
20.31999969 | 0.244685143 |
20.13999939 | 0.244306162 |
19.92000008 | 0.244005546 |
19.77000046 | 0.243800476 |
19.56999969 | 0.243406251 |
19.31999969 | 0.243300855 |
19.12000084 | 0.242946893 |
18.92000008 | 0.242748469 |
18.71999931 | 0.24243106 |
18.52000046 | 0.242171213 |
18.31999969 | 0.242056981 |
18.17000008 | 0.241781354 |
17.92000008 | 0.241629571 |
17.71999931 | 0.241456255 |
17.52000046 | 0.241409719 |
17.31999969 | 0.241192609 |
17.12000084 | 0.241008878 |
16.92000008 | 0.241027594 |
16.71999931 | 0.240784839 |
16.54999924 | 0.240591735 |
16.31999969 | 0.240471795 |
16.12000084 | 0.240396723 |
15.92000008 | 0.240146056 |
15.72000027 | 0.239994839 |
15.52000046 | 0.239879593 |
15.31999969 | 0.239714086 |
15.17000008 | 0.239571378 |
14.92000008 | 0.239323914 |
14.72000027 | 0.239161804 |
14.53999996 | 0.239066809 |
14.31999969 | 0.238902196 |
14.11999989 | 0.238841713 |
13.92000008 | 0.238734812 |
13.72000027 | 0.238687903 |
13.52000046 | 0.238492489 |
13.31999969 | 0.238415703 |
13.11999989 | 0.238240093 |
12.94999981 | 0.238196448 |
12.72000027 | 0.238090068 |
12.52000046 | 0.237997413 |
12.31999969 | 0.237959802 |
12.11999989 | 0.237707168 |
11.92000008 | 0.237703905 |
11.72000027 | 0.23764579 |
11.52000046 | 0.237563506 |
11.31999969 | 0.237518922 |
11.11999989 | 0.237495348 |
10.92000008 | 0.237405315 |
10.72000027 | 0.23731786 |
10.52000046 | 0.237466857 |
10.31999969 | 0.237433851 |
10.17000008 | 0.237485856 |
9.920000076 | 0.237137243 |