Rooobert commited on
Commit
c4877ab
·
verified ·
1 Parent(s): a121197

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py CHANGED
@@ -6,6 +6,25 @@ import time
6
  import matplotlib.pyplot as plt
7
  import seaborn as sns
8
  from datetime import datetime
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
  # Set page config
11
  st.set_page_config(
@@ -55,6 +74,10 @@ def scrape_pchome(keyword, page_num):
55
 
56
  # Function to create analysis plots
57
  def create_analysis_plots(df):
 
 
 
 
58
  # Basic statistics
59
  st.subheader("基本統計資訊")
60
  col1, col2, col3 = st.columns(3)
 
6
  import matplotlib.pyplot as plt
7
  import seaborn as sns
8
  from datetime import datetime
9
+ import matplotlib as mpl
10
+ import matplotlib.font_manager as fm
11
+ import os
12
+ import urllib.request
13
+
14
+ # 下載並設定中文字型
15
+ def setup_chinese_font():
16
+ font_path = 'TaipeiSansTCBeta-Regular.ttf'
17
+ if not os.path.exists(font_path):
18
+ font_url = "https://drive.google.com/uc?id=1eGAsTN1HBpJAkeVM57_C7ccp7hbgSz3_&export=download"
19
+ urllib.request.urlretrieve(font_url, font_path)
20
+
21
+ # 設定字型
22
+ fm.fontManager.addfont(font_path)
23
+ plt.rcParams['font.family'] = 'Taipei Sans TC Beta'
24
+ mpl.rc('font', family='Taipei Sans TC Beta')
25
+
26
+ # 設定中文字型
27
+ setup_chinese_font()
28
 
29
  # Set page config
30
  st.set_page_config(
 
74
 
75
  # Function to create analysis plots
76
  def create_analysis_plots(df):
77
+ # 設定全域字型樣式
78
+ plt.rcParams['font.sans-serif'] = ['Taipei Sans TC Beta']
79
+ plt.rcParams['axes.unicode_minus'] = False
80
+
81
  # Basic statistics
82
  st.subheader("基本統計資訊")
83
  col1, col2, col3 = st.columns(3)