使用“Times New Roman”同時為 Matplotlib 標題設定粗體
要在使用“Times New Roman”的同時將 Matplotlib 標題設定為粗體,我們可以使用 fontweight="bold"。
步驟
- 設定圖形大小,並調整子圖之間的和周圍的邊距。
- 建立圖形和一組子圖。
- 使用 numpy 建立 x 和 y 資料點。
- 使用 scatter() 方法繪製 x 和 y 資料點。
- 使用 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()輸出

廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP