注釋文本箭頭
結(jié)果展示:

完整代碼示例:
import numpy as npimport matplotlib.pyplot as pltfig, ax = plt.subplots(figsize=(5, 5))ax.set_aspect(1)x1 = -1 + np.random.randn(100)y1 = -1 + np.random.randn(100)x2 = 1. + np.random.randn(100)y2 = 1. + np.random.randn(100)ax.scatter(x1, y1, color="r")ax.scatter(x2, y2, color="g")bbox_props = dict(boxstyle="round", fc="w", ec="0.5", alpha=0.9)ax.text(-2, -2, "Sample A", ha="center", va="center", size=20, bbox=bbox_props)ax.text(2, 2, "Sample B", ha="center", va="center", size=20, bbox=bbox_props)bbox_props = dict(boxstyle="rarrow", fc=(0.8, 0.9, 0.9), ec="b", lw=2)t = ax.text(0, 0, "Direction", ha="center", va="center", rotation=45, size=15, bbox=bbox_props)bb = t.get_bbox_patch()bb.set_boxstyle("rarrow", pad=0.6)ax.set_xlim(-4, 4)ax.set_ylim(-4, 4)plt.show()總結(jié)
以上就是本文關(guān)于python matplotlib 注釋文本箭頭簡單代碼示例的全部內(nèi)容,希望對大家有所幫助。感興趣的朋友可以繼續(xù)參閱本站:
《matplotlib繪制動畫代碼示例》
《python+matplotlib繪制簡單的海豚(頂點(diǎn)和節(jié)點(diǎn)的操作)》
《Python通過matplotlib畫雙層餅圖及環(huán)形圖簡單示例》
如有不足之處,歡迎留言指出。感謝朋友們對本站的支持!
新聞熱點(diǎn)
疑難解答
圖片精選