ile resim ve arsa birleştirme X ekseninde zaman damgaları ve y ekseninde bazı sinyal verisi olan bir çizimim var. Bir dokümantasyon olarak, arsadaki belirli noktalara göre zaman damgalı resimler koymak istiyorum. Bir arsada bir çizgiyi, arsanın altındaki resimlerin bir dizisinde çizmek mümkün mü?Python Matplotlib
14
A
cevap
16
matplotlib galerisindeki demo, resimlerin nasıl ekleneceğini, çizgilerin nasıl çizileceğini vb. Gösterir. Görseli galeriden gönderirim ve kodu görmek için link'u takip edebilirsiniz. Ben doğru soruyu anlamak
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.patches import Circle
from matplotlib.offsetbox import (TextArea, DrawingArea, OffsetImage,
AnnotationBbox)
from matplotlib.cbook import get_sample_data
if 1:
fig, ax = plt.subplots()
# Define a 1st position to annotate (display it with a marker)
xy = (0.5, 0.7)
ax.plot(xy[0], xy[1], ".r")
# Annotate the 1st position with a text box ('Test 1')
offsetbox = TextArea("Test 1", minimumdescent=False)
ab = AnnotationBbox(offsetbox, xy,
xybox=(-20, 40),
xycoords='data',
boxcoords="offset points",
arrowprops=dict(arrowstyle="->"))
ax.add_artist(ab)
# Annotate the 1st position with another text box ('Test')
offsetbox = TextArea("Test", minimumdescent=False)
ab = AnnotationBbox(offsetbox, xy,
xybox=(1.02, xy[1]),
xycoords='data',
boxcoords=("axes fraction", "data"),
box_alignment=(0., 0.5),
arrowprops=dict(arrowstyle="->"))
ax.add_artist(ab)
# Define a 2nd position to annotate (don't display with a marker this time)
xy = [0.3, 0.55]
# Annotate the 2nd position with a circle patch
da = DrawingArea(20, 20, 0, 0)
p = Circle((10, 10), 10)
da.add_artist(p)
ab = AnnotationBbox(da, xy,
xybox=(1.02, xy[1]),
xycoords='data',
boxcoords=("axes fraction", "data"),
box_alignment=(0., 0.5),
arrowprops=dict(arrowstyle="->"))
ax.add_artist(ab)
# Annotate the 2nd position with an image (a generated array of pixels)
arr = np.arange(100).reshape((10, 10))
im = OffsetImage(arr, zoom=2)
im.image.axes = ax
ab = AnnotationBbox(im, xy,
xybox=(-50., 50.),
xycoords='data',
boxcoords="offset points",
pad=0.3,
arrowprops=dict(arrowstyle="->"))
ax.add_artist(ab)
# Annotate the 2nd position with another image (a Grace Hopper portrait)
fn = get_sample_data("grace_hopper.png", asfileobj=False)
arr_img = plt.imread(fn, format='png')
imagebox = OffsetImage(arr_img, zoom=0.2)
imagebox.image.axes = ax
ab = AnnotationBbox(imagebox, xy,
xybox=(120., -80.),
xycoords='data',
boxcoords="offset points",
pad=0.5,
arrowprops=dict(
arrowstyle="->",
connectionstyle="angle,angleA=0,angleB=90,rad=3")
)
ax.add_artist(ab)
# Fix the display limits to see everything
ax.set_xlim(0, 1)
ax.set_ylim(0, 1)
plt.show()
14
, o zaman belki bu yardımcı olabilir:
Ve burada (sürümünden 2.1.2 itibaren) kod
import scipy
import pylab
fig = pylab.figure()
axplot = fig.add_axes([0.07,0.25,0.90,0.70])
axplot.plot(scipy.randn(100))
numicons = 8
for k in range(numicons):
axicon = fig.add_axes([0.07+0.11*k,0.05,0.1,0.1])
axicon.imshow(scipy.rand(4,4),interpolation='nearest')
axicon.set_xticks([])
axicon.set_yticks([])
fig.show()
fig.savefig('iconsbelow.png')
+0
Görüntülerin etrafındaki siyah kenarlar istenmeyen olduğunda, 'axicon.set_xticks ([]) 've' axicon.set_yticks ([]) 'komutları axicon.axis ('off') 'ile değiştirilebilir. –
İlgili konular
- 1. Matplotlib, Python
- 2. Matplotlib/Python
- 3. Matplotlib - Python hata
- 4. Python: Matplotlib Surface_plot
- 5. Python matplotlib Şekil
- 6. Göm Python/Numpy/Matplotlib?
- 7. Matplotlib
- 8. Matplotlib
- 9. python matplotlib - kontur çizim - güven aralığı
- 10. PyQt ve matplotlib kullanırken belleği sızdıran Python
- 11. Python - matplotlib griddata için çoklu işleme
- 12. Python 3'te matplotlib içe aktarılamıyor
- 13. Python Matplotlib - Imsave ile şekil boyutlarını daraltma
- 14. Python'da Yeni ... Python 3 ve Matplotlib
- 15. python matplotlib imshow() özel onay işaretleri
- 16. python ve matplotlib içinde güncelleme şekli
- 17. Python matplotlib colorbar etiketlerinin boyutunu azaltın
- 18. python matplotlib kısa çizgi nokta - nasıl yapılır?
- 19. Python grafiği Matplotlib kullanarak büyük matris
- 20. python matplotlib animasyonu durdur/başlat/duraklat Animasyon
- 21. Arsa Mandelbrot, matplotlib/pyplot/numpy/python ile
- 22. ImportError: 'matplotlib' modül adı yok Python 3.3
- 23. Matplotlib Animasyon
- 24. matplotlib
- 25. Matplotlib
- 26. Matplotlib
- 27. matplotlib
- 28. Matplotlib
- 29. matplotlib
- 30. Matplotlib
mu Bunun 3D olarak çalışıp çalışmadığını bilen var mı? bir uçağa resim ekleyebilir miyiz? – CromeX
@CromeX: lütfen ayrı bir soru sorun. – tom10
bağlantıları artık çalışmıyor. –