Untitled
unknown
plain_text
10 months ago
1.4 kB
9
Indexable
# Draw comparison: A3 paper vs bounding rectangle (kotak besar)
from matplotlib.patches import Rectangle
import matplotlib.pyplot as plt
# A3 size (cm)
a3_w, a3_h = 42.0, 29.7
# Bounding rectangle (kotak besar)
big_w, big_h = 37.0, 22.0
# Figure scale: convert to inches (1 inch = 2.54 cm)
fig_w_inches = a3_w / 2.54
fig_h_inches = a3_h / 2.54
fig, ax = plt.subplots(figsize=(fig_w_inches/2, fig_h_inches/2), dpi=150) # smaller view
# Draw A3 paper outline
a3_rect = Rectangle((0, 0), a3_w, a3_h, fill=False, edgecolor="black", linewidth=2, label="Kertas A3 (42×29.7 cm)")
ax.add_patch(a3_rect)
# Draw bounding rectangle centered
x_margin = (a3_w - big_w) / 2
y_margin = (a3_h - big_h) / 2
big_rect = Rectangle((x_margin, y_margin), big_w, big_h, fill=False, edgecolor="red", linewidth=2, label="Kotak besar (37×22 cm)")
ax.add_patch(big_rect)
# Labels
ax.text(a3_w/2, -1, "Lebar A3 = 42 cm", ha="center", va="top")
ax.text(-1, a3_h/2, "Tinggi A3 = 29.7 cm", ha="right", va="center", rotation=90)
ax.text(a3_w/2, y_margin + big_h/2, "Kotak besar 37×22 cm", color="red", ha="center", va="center")
# Formatting
ax.set_xlim(-2, a3_w+2)
ax.set_ylim(-2, a3_h+2)
ax.set_aspect('equal')
ax.axis("off")
plt.legend(loc="upper right")
out_path = "/mnt/data/a3_vs_kotak.png"
plt.savefig(out_path, bbox_inches="tight", dpi=150)
plt.show()
print(f"[Download perbandingan gambar]({out_path})")Editor is loading...
Leave a Comment