2
A
回答
2
的AnnotationBox
模塊中matplotlib有助於在可視化繪製的圖像,而不是點
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.offsetbox import OffsetImage, AnnotationBbox
from matplotlib.cbook import get_sample_data
def main():
x = np.linspace(0, 10, 20)
y = np.cos(x)
image_path = get_sample_data('pic.png')
fig, ax = plt.subplots()
imscatter(x, y, image_path, zoom=0.1, ax=ax)
ax.plot(x, y)
plt.show()
def imscatter(x, y, image, ax=None, zoom=1):
if ax is None:
ax = plt.gca()
try:
image = plt.imread(image)
except TypeError:
pass
im = OffsetImage(image, zoom=zoom)
x, y = np.atleast_1d(x, y)
artists = []
for x0, y0 in zip(x, y):
ab = AnnotationBbox(im, (x0, y0), xycoords='data', frameon=False)
artists.append(ax.add_artist(ab))
ax.update_datalim(np.column_stack([x, y]))
ax.autoscale()
return artists
main()
所得圖像:
相關問題
- 1. 與matplotlib
- 2. 與matplotlib
- 3. 與Matplotlib
- 4. 與matplotlib
- 5. 與matplotlib
- 6. 與matplotlib
- 7. 與Matplotlib
- 8. 與matplotlib
- 9. 與Matplotlib
- 10. 錯誤與matplotlib
- 11. 映射與matplotlib
- 12. 繪製與matplotlib
- 13. 日期與matplotlib
- 14. IndexError與matplotlib
- 15. 繪製與Matplotlib
- 16. 情節與matplotlib
- 17. 與OO Matplotlib
- 18. 磚牆與matplotlib
- 19. Matplotlib與PyQt5
- 20. 產生與matplotlib
- 21. 請與matplotlib
- 22. 問題與matplotlib
- 23. 與matplotlib GridSpec
- 24. plt.figure()與在Matplotlib
- 25. 繪製與matplotlib
- 26. Tkinter的與matplotlib
- 27. 條形圖與Matplotlib
- 28. 頻率圖與matplotlib
- 29. 獲取PySide與matplotlib
- 30. 直方圖與matplotlib
無論如何要繪製每點一個符號? – gdlm
幫助,謝謝 – gdlm