Update app.py
Browse files
app.py
CHANGED
@@ -59,7 +59,7 @@ if st.button("開始搜索"):
|
|
59 |
st.write(f"MOMO 最高價格: {momo_df['price'].max():.2f}")
|
60 |
st.write(f"MOMO 最低價格: {momo_df['price'].min():.2f}")
|
61 |
|
62 |
-
# MOMO visualization
|
63 |
font_url = "https://drive.google.com/uc?id=1eGAsTN1HBpJAkeVM57_C7ccp7hbgSz3_&export=download"
|
64 |
font_response = requests.get(font_url)
|
65 |
with open("TaipeiSansTCBeta-Regular.ttf", "wb") as font_file:
|
@@ -67,17 +67,16 @@ if st.button("開始搜索"):
|
|
67 |
fm.fontManager.addfont("TaipeiSansTCBeta-Regular.ttf")
|
68 |
mpl.rc('font', family='Taipei Sans TC Beta')
|
69 |
|
70 |
-
fig, ax = plt.subplots(figsize=(
|
71 |
-
momo_df['price'][:70]
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
ax.set_facecolor('#f8f8f8')
|
81 |
plt.tight_layout()
|
82 |
st.pyplot(fig)
|
83 |
else:
|
|
|
59 |
st.write(f"MOMO 最高價格: {momo_df['price'].max():.2f}")
|
60 |
st.write(f"MOMO 最低價格: {momo_df['price'].min():.2f}")
|
61 |
|
62 |
+
# MOMO visualization - Unified with PCHOME
|
63 |
font_url = "https://drive.google.com/uc?id=1eGAsTN1HBpJAkeVM57_C7ccp7hbgSz3_&export=download"
|
64 |
font_response = requests.get(font_url)
|
65 |
with open("TaipeiSansTCBeta-Regular.ttf", "wb") as font_file:
|
|
|
67 |
fm.fontManager.addfont("TaipeiSansTCBeta-Regular.ttf")
|
68 |
mpl.rc('font', family='Taipei Sans TC Beta')
|
69 |
|
70 |
+
fig, ax = plt.subplots(figsize=(15, 8))
|
71 |
+
ax.plot(momo_df.index[:70], momo_df['price'][:70], 'o', color='skyblue', markersize=8)
|
72 |
+
ax.set_title(f'MOMO 電商網站上 "{search_keyword}" 的銷售價格', fontsize=20, fontweight='bold')
|
73 |
+
ax.axhline(y=momo_avg_price, color='red', linestyle='--', linewidth=2, label=f'參考價格: {momo_avg_price:.2f}')
|
74 |
+
ax.set_xlabel('商品索引', fontsize=14)
|
75 |
+
ax.set_ylabel('價格', fontsize=14)
|
76 |
+
ax.tick_params(axis='x', rotation=45, labelsize=12)
|
77 |
+
ax.tick_params(axis='y', labelsize=12)
|
78 |
+
ax.legend(fontsize=12, loc='upper left')
|
79 |
+
ax.grid(axis='y', linestyle='--', alpha=0.7)
|
|
|
80 |
plt.tight_layout()
|
81 |
st.pyplot(fig)
|
82 |
else:
|