質問編集履歴
3
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
ピーク検出後その値を用いてピークフィッティングをしたいです
|
test
CHANGED
@@ -5,266 +5,6 @@
|
|
5
5
|
あるデータを用いて①ピーク検出②その検出した値からピークフィッティングを用いてピークを求めるのを一つにまとめたいです
|
6
6
|
|
7
7
|
色々サイトを見て進めているのでごちゃごちゃしていると思うので省略できそうな部分があればそれも教えて頂きたいです
|
8
|
-
|
9
|
-
### ①ピーク検出
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
```Python
|
14
|
-
|
15
|
-
import pandas as pd
|
16
|
-
|
17
|
-
import numpy as np
|
18
|
-
|
19
|
-
from scipy import signal
|
20
|
-
|
21
|
-
import matplotlib.pyplot as plt
|
22
|
-
|
23
|
-
import os
|
24
|
-
|
25
|
-
from scipy.signal import find_peaks
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
x, y = np.loadtxt("./2_BLT_powder_2th-ome.txt",skiprows=29, unpack=True)
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
peaks, _ = find_peaks(x, height=200)
|
38
|
-
|
39
|
-
#signal.find_peaks(x, height=高さ, distance=距離)
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
maxid = signal.argrelmax(y, order=100) #極大値 orderを変えることでピークの検出が変わる(ピーク検出の閾値)
|
44
|
-
|
45
|
-
#minid = signal.argrelmin(y, order=1) #極小値
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
x_max = max(x)
|
54
|
-
|
55
|
-
y_max = max(y)
|
56
|
-
|
57
|
-
y_min = min(y)
|
58
|
-
|
59
|
-
x_min = min(x)
|
60
|
-
|
61
|
-
fig=plt.figure(figsize=(15,5))#図のアスペクト比を変更(横×縦)
|
62
|
-
|
63
|
-
Map1 = fig.add_subplot(111)
|
64
|
-
|
65
|
-
Map1.plot(x, y)
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
#plt.plot((x, y), pltsize=(6,6))
|
70
|
-
|
71
|
-
plt.tick_params(labelsize = 9)#目盛りの数字の大きさを変更
|
72
|
-
|
73
|
-
plt.ylim(y_min, y_max*1.1) # y 軸の範囲の設定,
|
74
|
-
|
75
|
-
plt.xlim(10,65) # x 軸の範囲の設定
|
76
|
-
|
77
|
-
#plt.show()
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
plt.plot(x[maxid],y[maxid],'ro',label='peak_max')
|
82
|
-
|
83
|
-
#plt.plot(x[minid],y[minid],'bo',label='ピーク値(最小)')
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
plt.legend()
|
92
|
-
|
93
|
-
print(x[maxid])
|
94
|
-
|
95
|
-
print(y[maxid])
|
96
|
-
|
97
|
-
```
|
98
|
-
|
99
|
-
###②ピークフィッティング
|
100
|
-
|
101
|
-
```Python
|
102
|
-
|
103
|
-
from scipy.optimize import curve_fit
|
104
|
-
|
105
|
-
import numpy as np
|
106
|
-
|
107
|
-
import matplotlib.pyplot as plt
|
108
|
-
|
109
|
-
import matplotlib.cm as cm
|
110
|
-
|
111
|
-
import pandas as pd
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
x, y = np.loadtxt("./2_BLT_powder_2th-ome.txt",skiprows=29, unpack=True)
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
def func(x, *params):
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
#paramsの長さでフィッティングする関数の数を判別。
|
126
|
-
|
127
|
-
num_func = int(len(params)/3)
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
#ガウス関数にそれぞれのパラメータを挿入してy_listに追加。
|
132
|
-
|
133
|
-
y_list = []
|
134
|
-
|
135
|
-
for i in range(num_func):
|
136
|
-
|
137
|
-
y = np.zeros_like(x)
|
138
|
-
|
139
|
-
param_range = list(range(3*i,3*(i+1),1))
|
140
|
-
|
141
|
-
amp = params[int(param_range[0])]
|
142
|
-
|
143
|
-
ctr = params[int(param_range[1])]
|
144
|
-
|
145
|
-
wid = params[int(param_range[2])]
|
146
|
-
|
147
|
-
y = y + amp * np.exp( -((x - ctr)/wid)**2)
|
148
|
-
|
149
|
-
y_list.append(y)
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
#y_listに入っているすべてのガウス関数を重ね合わせる。
|
154
|
-
|
155
|
-
y_sum = np.zeros_like(x)
|
156
|
-
|
157
|
-
for i in y_list:
|
158
|
-
|
159
|
-
y_sum = y_sum + i
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
#最後にバックグラウンドを追加。
|
164
|
-
|
165
|
-
y_sum = y_sum + params[-1]
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
return y_sum
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
#プロットの定義
|
174
|
-
|
175
|
-
def fit_plot(x, *params):
|
176
|
-
|
177
|
-
num_func = int(len(params)/3)
|
178
|
-
|
179
|
-
y_list = []
|
180
|
-
|
181
|
-
for i in range(num_func):
|
182
|
-
|
183
|
-
y = np.zeros_like(x)
|
184
|
-
|
185
|
-
param_range = list(range(3*i,3*(i+1),1))
|
186
|
-
|
187
|
-
amp = params[int(param_range[0])]
|
188
|
-
|
189
|
-
ctr = params[int(param_range[1])]
|
190
|
-
|
191
|
-
wid = params[int(param_range[2])]
|
192
|
-
|
193
|
-
y = y + amp * np.exp( -((x - ctr)/wid)**2) + params[-1]
|
194
|
-
|
195
|
-
y_list.append(y)
|
196
|
-
|
197
|
-
return y_list
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
#初期値のリストを作成
|
202
|
-
|
203
|
-
#[amp,ctr,wid]
|
204
|
-
|
205
|
-
x1=float(input("x1"))
|
206
|
-
|
207
|
-
y1=float(input("y1"))
|
208
|
-
|
209
|
-
x2=float(input("x2"))
|
210
|
-
|
211
|
-
y2=float(input("y2"))
|
212
|
-
|
213
|
-
guess = []
|
214
|
-
|
215
|
-
guess.append([y1, x1, 1])
|
216
|
-
|
217
|
-
guess.append([y2, x2, 1])
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
#バックグラウンドの初期値
|
222
|
-
|
223
|
-
background = 70
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
#初期値リストの結合
|
228
|
-
|
229
|
-
guess_total = []
|
230
|
-
|
231
|
-
for i in guess:
|
232
|
-
|
233
|
-
guess_total.extend(i)
|
234
|
-
|
235
|
-
guess_total.append(background)
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
popt, pcov = curve_fit(func, x, y, p0=guess_total)
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
fit= func(x, *popt)
|
248
|
-
|
249
|
-
plt.scatter(x, y, s=20)
|
250
|
-
|
251
|
-
plt.plot(x, fit , ls='-', c='black', lw=1)
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
y_list = fit_plot(x, *popt)
|
256
|
-
|
257
|
-
baseline = np.zeros_like(x) + popt[-1]
|
258
|
-
|
259
|
-
for n,i in enumerate(y_list):
|
260
|
-
|
261
|
-
plt.fill_between(x, i, baseline, facecolor=cm.rainbow(n/len(y_list)), alpha=0.6)
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
print(*popt)
|
266
|
-
|
267
|
-
```
|
268
8
|
|
269
9
|
### 実現したいこと
|
270
10
|
|
@@ -274,217 +14,9 @@
|
|
274
14
|
|
275
15
|
|
276
16
|
|
277
|
-
###追記
|
278
|
-
|
279
|
-
```Python
|
280
|
-
|
281
|
-
from scipy.optimize import curve_fit
|
282
|
-
|
283
|
-
import matplotlib.pyplot as plt
|
284
|
-
|
285
|
-
import matplotlib.cm as cm
|
286
|
-
|
287
|
-
import pandas as pd
|
288
|
-
|
289
|
-
import numpy as np
|
290
|
-
|
291
|
-
from scipy import signal
|
292
|
-
|
293
|
-
import os
|
294
|
-
|
295
|
-
from scipy.signal import find_peaks
|
296
17
|
|
297
18
|
|
298
19
|
|
299
|
-
|
300
|
-
|
301
|
-
x, y = np.loadtxt("./2_BLT_powder_2th-ome.txt", skiprows=29, unpack=True)
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
def detect_peak():
|
308
|
-
|
309
|
-
global x
|
310
|
-
|
311
|
-
global y
|
312
|
-
|
313
|
-
#signal.find_peaks(x, height=高さ, distance=距離)
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
# 極大値 orderを変えることでピークの検出が変わる(ピーク検出の閾値)
|
318
|
-
|
319
|
-
maxid = signal.argrelmax(y, order=100)
|
320
|
-
|
321
|
-
# minid = signal.argrelmin(y, order=1) #極小値
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
plt.plot(x[maxid], y[maxid], 'ro', label='peak_max')
|
328
|
-
|
329
|
-
# plt.plot(x[minid],y[minid],'bo',label='ピーク値(最小)')
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
return x[maxid], y[maxid]
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
def func(x, *params):
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
#paramsの長さでフィッティングする関数の数を判別。
|
342
|
-
|
343
|
-
num_func = int(len(params)/3)
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
#ガウス関数にそれぞれのパラメータを挿入してy_listに追加。
|
348
|
-
|
349
|
-
y_list = []
|
350
|
-
|
351
|
-
for i in range(num_func):
|
352
|
-
|
353
|
-
y = np.zeros_like(x)
|
354
|
-
|
355
|
-
param_range = list(range(3*i,3*(i+1),1))
|
356
|
-
|
357
|
-
amp = params[int(param_range[0])]
|
358
|
-
|
359
|
-
ctr = params[int(param_range[1])]
|
360
|
-
|
361
|
-
wid = params[int(param_range[2])]
|
362
|
-
|
363
|
-
y = y + amp * np.exp( -((x - ctr)/wid)**2)
|
364
|
-
|
365
|
-
y_list.append(y)
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
#y_listに入っているすべてのガウス関数を重ね合わせる。
|
370
|
-
|
371
|
-
y_sum = np.zeros_like(x)
|
372
|
-
|
373
|
-
for i in y_list:
|
374
|
-
|
375
|
-
y_sum = y_sum + i
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
#最後にバックグラウンドを追加。
|
380
|
-
|
381
|
-
y_sum = y_sum + params[-1]
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
return y_sum
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
#プロットの定義
|
390
|
-
|
391
|
-
def fit_plot(x, *params):
|
392
|
-
|
393
|
-
num_func = int(len(params)/3)
|
394
|
-
|
395
|
-
y_list = []
|
396
|
-
|
397
|
-
for i in range(num_func):
|
398
|
-
|
399
|
-
y = np.zeros_like(x)
|
400
|
-
|
401
|
-
param_range = list(range(3*i,3*(i+1),1))
|
402
|
-
|
403
|
-
amp = params[int(param_range[0])]
|
404
|
-
|
405
|
-
ctr = params[int(param_range[1])]
|
406
|
-
|
407
|
-
wid = params[int(param_range[2])]
|
408
|
-
|
409
|
-
y = y + amp * np.exp( -((x - ctr)/wid)**2) + params[-1]
|
410
|
-
|
411
|
-
y_list.append(y)
|
412
|
-
|
413
|
-
return y_list
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
#初期値のリストを作成
|
418
|
-
|
419
|
-
#[amp,ctr,wid]
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
# x1, y1 = detect_peak() ##
|
424
|
-
|
425
|
-
np_x, np_y = detect_peak() ##
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
# guess = [] ##
|
432
|
-
|
433
|
-
guess = [[y1, x1, 1] for (x1, y1) in zip(np_x, np_y)] ##
|
434
|
-
|
435
|
-
# guess.append([y1, x1, 1]) ##
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
#バックグラウンドの初期値
|
442
|
-
|
443
|
-
background = 70
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
#初期値リストの結合
|
448
|
-
|
449
|
-
guess_total = []
|
450
|
-
|
451
|
-
for i in guess:
|
452
|
-
|
453
|
-
guess_total.extend(i)
|
454
|
-
|
455
|
-
guess_total.append(background)
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
popt, pcov = curve_fit(func, x, y, p0=guess_total)
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
fit= func(x, *popt)
|
468
|
-
|
469
|
-
plt.scatter(x, y, s=20)
|
470
|
-
|
471
|
-
plt.plot(x, fit , ls='-', c='black', lw=1)
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
y_list = fit_plot(x, *popt)
|
476
|
-
|
477
|
-
baseline = np.zeros_like(x) + popt[-1]
|
478
|
-
|
479
|
-
for n,i in enumerate(y_list):
|
480
|
-
|
481
|
-
plt.fill_between(x, i, baseline, facecolor=cm.rainbow(n/len(y_list)), alpha=0.6)
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
print(*popt)
|
486
|
-
|
487
|
-
```
|
488
20
|
|
489
21
|
###追記部分エラーメッセージ
|
490
22
|
|
2
エラーコード追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -486,7 +486,43 @@
|
|
486
486
|
|
487
487
|
```
|
488
488
|
|
489
|
-
|
489
|
+
###追記部分エラーメッセージ
|
490
|
+
|
491
|
+
```Python
|
492
|
+
|
493
|
+
RuntimeError Traceback (most recent call last)
|
494
|
+
|
495
|
+
C:\Users\Public\Documents\Wondershare\CreatorTemp/ipykernel_9180/2660802360.py in <module>
|
496
|
+
|
497
|
+
88 guess_total.append(background)
|
498
|
+
|
499
|
+
89
|
500
|
+
|
501
|
+
---> 90 popt, pcov = curve_fit(func, x, y, p0=guess_total)
|
502
|
+
|
503
|
+
91
|
504
|
+
|
505
|
+
92
|
506
|
+
|
507
|
+
|
508
|
+
|
509
|
+
~\AppData\Local\Programs\Python\Python39\lib\site-packages\scipy\optimize\minpack.py in curve_fit(f, xdata, ydata, p0, sigma, absolute_sigma, check_finite, bounds, method, jac, **kwargs)
|
510
|
+
|
511
|
+
792 cost = np.sum(infodict['fvec'] ** 2)
|
512
|
+
|
513
|
+
793 if ier not in [1, 2, 3, 4]:
|
514
|
+
|
515
|
+
--> 794 raise RuntimeError("Optimal parameters not found: " + errmsg)
|
516
|
+
|
517
|
+
795 else:
|
518
|
+
|
519
|
+
796 # Rename maxfev (leastsq) to max_nfev (least_squares), if specified.
|
520
|
+
|
521
|
+
|
522
|
+
|
523
|
+
RuntimeError: Optimal parameters not found: Number of calls to function has reached maxfev = 14200.
|
524
|
+
|
525
|
+
```
|
490
526
|
|
491
527
|
|
492
528
|
|
1
コードの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -274,6 +274,220 @@
|
|
274
274
|
|
275
275
|
|
276
276
|
|
277
|
+
###追記
|
278
|
+
|
279
|
+
```Python
|
280
|
+
|
281
|
+
from scipy.optimize import curve_fit
|
282
|
+
|
283
|
+
import matplotlib.pyplot as plt
|
284
|
+
|
285
|
+
import matplotlib.cm as cm
|
286
|
+
|
287
|
+
import pandas as pd
|
288
|
+
|
289
|
+
import numpy as np
|
290
|
+
|
291
|
+
from scipy import signal
|
292
|
+
|
293
|
+
import os
|
294
|
+
|
295
|
+
from scipy.signal import find_peaks
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
x, y = np.loadtxt("./2_BLT_powder_2th-ome.txt", skiprows=29, unpack=True)
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
|
306
|
+
|
307
|
+
def detect_peak():
|
308
|
+
|
309
|
+
global x
|
310
|
+
|
311
|
+
global y
|
312
|
+
|
313
|
+
#signal.find_peaks(x, height=高さ, distance=距離)
|
314
|
+
|
315
|
+
|
316
|
+
|
317
|
+
# 極大値 orderを変えることでピークの検出が変わる(ピーク検出の閾値)
|
318
|
+
|
319
|
+
maxid = signal.argrelmax(y, order=100)
|
320
|
+
|
321
|
+
# minid = signal.argrelmin(y, order=1) #極小値
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
plt.plot(x[maxid], y[maxid], 'ro', label='peak_max')
|
328
|
+
|
329
|
+
# plt.plot(x[minid],y[minid],'bo',label='ピーク値(最小)')
|
330
|
+
|
331
|
+
|
332
|
+
|
333
|
+
return x[maxid], y[maxid]
|
334
|
+
|
335
|
+
|
336
|
+
|
337
|
+
def func(x, *params):
|
338
|
+
|
339
|
+
|
340
|
+
|
341
|
+
#paramsの長さでフィッティングする関数の数を判別。
|
342
|
+
|
343
|
+
num_func = int(len(params)/3)
|
344
|
+
|
345
|
+
|
346
|
+
|
347
|
+
#ガウス関数にそれぞれのパラメータを挿入してy_listに追加。
|
348
|
+
|
349
|
+
y_list = []
|
350
|
+
|
351
|
+
for i in range(num_func):
|
352
|
+
|
353
|
+
y = np.zeros_like(x)
|
354
|
+
|
355
|
+
param_range = list(range(3*i,3*(i+1),1))
|
356
|
+
|
357
|
+
amp = params[int(param_range[0])]
|
358
|
+
|
359
|
+
ctr = params[int(param_range[1])]
|
360
|
+
|
361
|
+
wid = params[int(param_range[2])]
|
362
|
+
|
363
|
+
y = y + amp * np.exp( -((x - ctr)/wid)**2)
|
364
|
+
|
365
|
+
y_list.append(y)
|
366
|
+
|
367
|
+
|
368
|
+
|
369
|
+
#y_listに入っているすべてのガウス関数を重ね合わせる。
|
370
|
+
|
371
|
+
y_sum = np.zeros_like(x)
|
372
|
+
|
373
|
+
for i in y_list:
|
374
|
+
|
375
|
+
y_sum = y_sum + i
|
376
|
+
|
377
|
+
|
378
|
+
|
379
|
+
#最後にバックグラウンドを追加。
|
380
|
+
|
381
|
+
y_sum = y_sum + params[-1]
|
382
|
+
|
383
|
+
|
384
|
+
|
385
|
+
return y_sum
|
386
|
+
|
387
|
+
|
388
|
+
|
389
|
+
#プロットの定義
|
390
|
+
|
391
|
+
def fit_plot(x, *params):
|
392
|
+
|
393
|
+
num_func = int(len(params)/3)
|
394
|
+
|
395
|
+
y_list = []
|
396
|
+
|
397
|
+
for i in range(num_func):
|
398
|
+
|
399
|
+
y = np.zeros_like(x)
|
400
|
+
|
401
|
+
param_range = list(range(3*i,3*(i+1),1))
|
402
|
+
|
403
|
+
amp = params[int(param_range[0])]
|
404
|
+
|
405
|
+
ctr = params[int(param_range[1])]
|
406
|
+
|
407
|
+
wid = params[int(param_range[2])]
|
408
|
+
|
409
|
+
y = y + amp * np.exp( -((x - ctr)/wid)**2) + params[-1]
|
410
|
+
|
411
|
+
y_list.append(y)
|
412
|
+
|
413
|
+
return y_list
|
414
|
+
|
415
|
+
|
416
|
+
|
417
|
+
#初期値のリストを作成
|
418
|
+
|
419
|
+
#[amp,ctr,wid]
|
420
|
+
|
421
|
+
|
422
|
+
|
423
|
+
# x1, y1 = detect_peak() ##
|
424
|
+
|
425
|
+
np_x, np_y = detect_peak() ##
|
426
|
+
|
427
|
+
|
428
|
+
|
429
|
+
|
430
|
+
|
431
|
+
# guess = [] ##
|
432
|
+
|
433
|
+
guess = [[y1, x1, 1] for (x1, y1) in zip(np_x, np_y)] ##
|
434
|
+
|
435
|
+
# guess.append([y1, x1, 1]) ##
|
436
|
+
|
437
|
+
|
438
|
+
|
439
|
+
|
440
|
+
|
441
|
+
#バックグラウンドの初期値
|
442
|
+
|
443
|
+
background = 70
|
444
|
+
|
445
|
+
|
446
|
+
|
447
|
+
#初期値リストの結合
|
448
|
+
|
449
|
+
guess_total = []
|
450
|
+
|
451
|
+
for i in guess:
|
452
|
+
|
453
|
+
guess_total.extend(i)
|
454
|
+
|
455
|
+
guess_total.append(background)
|
456
|
+
|
457
|
+
|
458
|
+
|
459
|
+
popt, pcov = curve_fit(func, x, y, p0=guess_total)
|
460
|
+
|
461
|
+
|
462
|
+
|
463
|
+
|
464
|
+
|
465
|
+
|
466
|
+
|
467
|
+
fit= func(x, *popt)
|
468
|
+
|
469
|
+
plt.scatter(x, y, s=20)
|
470
|
+
|
471
|
+
plt.plot(x, fit , ls='-', c='black', lw=1)
|
472
|
+
|
473
|
+
|
474
|
+
|
475
|
+
y_list = fit_plot(x, *popt)
|
476
|
+
|
477
|
+
baseline = np.zeros_like(x) + popt[-1]
|
478
|
+
|
479
|
+
for n,i in enumerate(y_list):
|
480
|
+
|
481
|
+
plt.fill_between(x, i, baseline, facecolor=cm.rainbow(n/len(y_list)), alpha=0.6)
|
482
|
+
|
483
|
+
|
484
|
+
|
485
|
+
print(*popt)
|
486
|
+
|
487
|
+
```
|
488
|
+
|
489
|
+
|
490
|
+
|
277
491
|
|
278
492
|
|
279
493
|
### 補足情報
|