發表文章

目前顯示的是 3月, 2026的文章

pyhon用matplotlib畫圖範例與設定字體

Python使用matplotlib畫圖範例 import matplotlib.pyplot as plt import numpy as np import os import zipfile # UserWarning: Glyph 26371 (\N{CJK UNIFIED IDEOGRAPH-6703}) missing from font(s) DejaVu Sans. from matplotlib import font_manager font_path = "/usr/share/fonts/opentype/noto/NotoSerifCJK-Medium.ttc" # 修改為字體實際路徑 font_prop = font_manager.FontProperties( fname = font_path) plt.rcParams[ "font.family" ] = font_prop.get_name() # Chart 1: 全球市場規模成長趨勢(折線圖) years = [ 2020 , 2024 , 2030 ] values = [ 60 , 280 , 1800 ] # 單位:十億美元 plt.figure() plt.plot(years, values, marker = 'o' , linestyle = '-' , color = 'blue' ) plt.title( "全球 AI 市場規模成長(十億美元)" ) plt.xlabel( "年份" ) plt.ylabel( "市場規模" ) plt.grid( True ) plt.tight_layout() # Prepare folder for images img_dir = "./ai_charts" os.makedirs(img_dir, exist_ok = True ) plt.savefig( f " { img_dir } /01_market_growth.png" ) plt.close()   Python列出matpl...