• # Generating decision flowchart for choosing between 御松園 and 宜蘭市一般建案 import matplotlib.pyplot as plt import matplotlib.patches as mpatches from matplotlib import rcParams import matplotlib.patheffects as path_effects # Set style plt.style.use('seaborn-v0_8-whitegrid') rcParams['figure.figsize'] = (12, 10) fig, ax = plt.subplots() ax.axis('off') # Define nodes and positions nodes = { "start": ("你是買方,想買宜蘭市新建案", (0.5, 1.0)), "q1": ("你是首購族或預算有限嗎?", (0.5, 0.85)), "q2": ("你重視建材品質與保固嗎?", (0.3, 0.7)), "q3": ("你喜歡社區生活與公設齊全嗎?", (0.7, 0.7)), "q4": ("你是為了投資或出租嗎?", (0.3, 0.55)), "q5": ("你重視付款安全嗎?", (0.7, 0.55)), "q6": ("你重視地段便利嗎?", (0.5, 0.4)), "御松園": ("✅ 適合:御松園", (0.7, 0.25)), "宜蘭建案": ("✅ 適合:宜蘭市一般建案", (0.3, 0.25)), } # Draw nodes for key, (text, pos) in nodes.items(): ax.text(pos[0], pos[1], text, ha='center', va='center', bbox=dict(boxstyle="round,pad=0.5", fc="lightblue" if "適合" in text else "white", ec="black"), fontsize=10, path_effects=[path_effects.withStroke(linewidth=1, foreground="black")]) # Draw arrows def draw_arrow(from_node, to_node, text=None, offset=(0, 0)): x0, y0 = nodes[from_node][1] x1, y1 = nodes[to_node][1] ax.annotate("", xy=(x1, y1), xycoords='data', xytext=(x0, y0), textcoords='data', arrowprops=dict(arrowstyle="->", lw=1.5)) if text: ax.text((x0 + x1)/2 + offset[0], (y0 + y1)/2 + offset[1], text, fontsize=9, ha='center') # Arrows from start draw_arrow("start", "q1") # q1 draw_arrow("q1", "宜蘭建案", "是", offset=(-0.1, 0.02)) draw_arrow("q1", "q2", "否", offset=(0.1, 0.02)) # q2 draw_arrow("q2", "御松園", "是", offset=(-0.1, 0.02)) draw_arrow("q2", "q4", "否", offset=(0.1, 0.02)) # q3 draw_arrow("q3", "御松園", "是", offset=(0.1, 0.02)) draw_arrow("q3", "q5", "否", offset=(-0.1, 0.02)) # q4 draw_arrow("q4", "宜蘭建案", "是", offset=(-0.1, 0.02)) draw_arrow("q4", "q3", "否", offset=(0.1, 0.02)) # q5 draw_arrow("q5", "御松園", "是", offset=(0.1, 0.02)) draw_arrow("q5", "q6", "否", offset=(-0.1, 0.02)) # q6 draw_arrow("q6", "宜蘭建案", "是", offset=(-0.1, 0.02)) draw_arrow("q6", "御松園", "否", offset=(0.1, 0.02)) # Save figure output_path = "/mnt/data/御松園_宜蘭建案_決策流程圖.png" plt.savefig(output_path, bbox_inches='tight') print("已建立御松園與宜蘭市建案的決策流程圖,檔案名稱為:御松園_宜蘭建案_決策流程圖.png")

  • 最後修改日期: 2025 年 12 月 20 日

    作者