|
@@ -173,8 +173,7 @@ async def get_trend_image(kw_id):
|
|
|
|
|
|
# create an array of numbers for the dates
|
|
|
x_dates = np.array([dates.date2num(i) for i in x])
|
|
|
- print(x)
|
|
|
- print(kw)
|
|
|
+
|
|
|
# create more uniform intervals in x axis and use spline to interpolate data
|
|
|
x_smooth = np.linspace(x_dates.min(), x_dates.max(), 200)
|
|
|
#y_smooth = spline(x_dates, y, x_smooth)
|
|
@@ -189,8 +188,7 @@ async def get_trend_image(kw_id):
|
|
|
plt.plot(x_new, y_smooth)
|
|
|
target_path = 'trend_image/'+kw+'.png'
|
|
|
plt.savefig(target_path)
|
|
|
- plt.savefig(target_path, bbox_inches='tight') #存檔,第二個參數表示把圖表外多餘的空間刪除
|
|
|
-
|
|
|
+
|
|
|
return FileResponse(target_path)
|
|
|
|
|
|
|