% 使用 MetaPost 畫方格紙 width := 50; % 寬有幾格 height := 50; % 高有幾格 s := 1mm; % 每格寬度 st := 5; % 每格代表數值 la := 10; % 每多少格標一次數值 fs := 10; % 字體大小 beginfig(1); % 設定字體大小 defaultscale := fs * pt / fontsize(defaultfont); % 畫水平的線 for i = 0 upto height: % 每 la 格會畫一次較粗的線條 if (i mod la = 0): draw (0, i * s)--(width * s, i * s) withpen pencircle scaled 0.5bp; else: draw (0, i * s)--(width * s, i * s) withpen pencircle scaled 0.2bp; fi; % 每 la 格會標一次數值 if (i mod la = 0) and (i > 0): label.lft( decimal(i * st), (0, i * s)); fi; endfor; % 畫垂直的線 for i = 0 upto width: % 每 la 格會畫一次較粗的線條 if (i mod la = 0): draw (i * s, 0)--(i * s, height * s) withpen pencircle scaled 0.5bp; else: draw (i * s, 0)--(i * s, height * s) withpen pencircle scaled 0.2bp; fi; % 每 la 格會標一次數值 if (i mod la = 0) and (i > 0): label.bot( decimal(i * st), (i * s, 0)); fi; endfor; % 畫原點 label.llft( "0", (0, 0)); endfig; bye;