Roberta2024 commited on
Commit
39d6306
·
verified ·
1 Parent(s): 078863a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -12
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=(30, 15))
71
- momo_df['price'][:70].plot(ax=ax, marker='o', linestyle='-', color='skyblue', linewidth=2, markersize=8)
72
- plt.title(f'MOMO 電商網站上 "{search_keyword}" 的銷售價格', fontsize=30, fontweight='bold', color='navy')
73
- plt.axhline(y=momo_avg_price, color='red', linestyle='--', linewidth=2, label=f'參考價格: {momo_avg_price:.2f}')
74
- plt.xlabel('商品索引', fontsize=20, color='gray')
75
- plt.ylabel('價格', fontsize=20, color='gray')
76
- plt.legend(fontsize=12, loc='upper left')
77
- plt.grid(axis='y', linestyle='--', alpha=0.5)
78
- plt.xticks(rotation=45, ha='right', fontsize=12, color='gray')
79
- plt.yticks(fontsize=12, color='gray')
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: