在 Matplotlib 中在圓圈內放置文字
若要在 matplotlib 中在圓圈內放置文字,我們可以採取以下步驟 −
使用 figure() 方法建立一個新圖形或啟用現有圖形。
向當前軸新增一個子圖方法。
使用Circle() 類建立圓形 例項。
在繪圖中新增圓形 路徑。
若要在圓圈中放置文字,我們可以使用 text() 方法。
使用 xlim() 和ylim() 方法縮放 x 和 y 軸。
若要顯示圖形,請使用 show() 方法。
示例
import matplotlib
from matplotlib import pyplot as plt, patches
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True
fig = plt.figure()
ax = fig.add_subplot(111)
circle = matplotlib.patches.Circle((0, 0), radius=1, color='yellow')
ax.add_patch(circle)
plt.text(-.25, 0, "This is a Circle")
plt.xlim([-4, 4])
plt.ylim([-4, 4])
plt.axis('equal')
plt.show()輸出

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