python matplotlib 注釋文本箭頭簡單程式碼範例,pythonmatplotlib

來源:互聯網
上載者:User

python matplotlib 注釋文本箭頭簡單程式碼範例,pythonmatplotlib

注釋文本箭頭

結果展示:

完整程式碼範例:

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()

總結

以上就是本文關於python matplotlib 注釋文本箭頭簡單程式碼範例的全部內容,希望對大家有所協助。感興趣的朋友可以繼續參閱本站:

《matplotlib繪製動畫程式碼範例》

《python+matplotlib繪製簡單的海豚(頂點和節點的操作)》

《Python通過matplotlib畫雙層餅圖及環形圖簡單樣本》

如有不足之處,歡迎留言指出。感謝朋友們對本站的支援!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.