ตั้งค่า facecolor และ edgecolors
- กำหนดขนาดรูปภาพและปรับระยะห่างระหว่างและรอบๆ subplots
- สร้าง figure ใหม่หรือเปิดใช้งาน figure ที่มีอยู่ด้วย figure()
- เพิ่ม axes เข้าไปใน figure เป็นส่วนหนึ่งของ subplot arrangement
- สร้างข้อมูล x, y และ z ด้วย numpy
- พล็อต x, y, z ด้วย scatter()
- ตั้งค่า facecolors และ edgecolors
- ใช้เมธอด show() เพื่อแสดงรูปภาพ
ตัวอย่างโค้ด
import numpy as np import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True fig = plt.figure() ax = fig.add_subplot(projection='3d') x = np.random.sample(20) y = np.random.sample(20) z = np.random.sample(20) s = ax.scatter(x, y, z, c="r") s._set_facecolors, s._set_edgecolors = s.set_facecolors, s.set_edgecolors plt.show()
ผลลัพธ์
