ในการตั้งชื่อ Matplotlib เป็นตัวหนาในขณะที่ใช้ "Times New Roman" เราสามารถใช้ fontweight="bold" .
ขั้นตอน
- กำหนดขนาดรูปและปรับช่องว่างภายในระหว่างและรอบๆ แผนผังย่อย
- สร้างร่างและชุดแผนย่อย
- สร้าง x และ ย จุดข้อมูลโดยใช้ตัวเลข
- พล็อต x และ ย จุดข้อมูลโดยใช้ scatter() วิธีการ
- ตั้งชื่อโครงเรื่องโดยใช้ fontname="Times New Roman" และ fontweight="bold"
- หากต้องการแสดงรูป ให้ใช้ show() วิธีการ
ตัวอย่าง
import numpy as np
from matplotlib import pyplot as plt, font_manager as fm
plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True
fig, ax = plt.subplots()
x = np.random.rand(100)
y = np.random.rand(100)
ax.scatter(x, y, c=y, marker="v")
ax.set_title('Scatter Plot With Random Points', fontname="Times New Roman", size=28,fontweight="bold")
plt.show() ผลลัพธ์
