के साथ चित्र और साजिश को मिलाएं मेरे पास एक प्लॉट है जिसमें एक्स-अक्ष पर टाइमस्टैम्प और वाई-अक्ष पर कुछ सिग्नल डेटा है। एक प्रलेखन के रूप में मैं साजिश में विशिष्ट बिंदुओं के संबंध में टाइमस्टैम्प चित्रों को रखना चाहता हूं। साजिश के नीचे चित्रों के अनुक्रम में एक तस्वीर में एक साजिश में एक रेखा खींचना संभव है?पायथन Matplotlib
14
A
उत्तर
16
This matplotlib गैलरी से डेमो दिखाता है कि कैसे चित्रों को सम्मिलित करना, उन्हें रेखाएं खींचना आदि। मैं गैलरी से छवि पोस्ट करूंगा, और आप कोड देखने के लिए link का पालन कर सकते हैं।
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
अगर मैं सवाल सही ढंग से समझ, तो शायद यह मदद मिल सकती है:
और यहाँ (संस्करण 2.1.2 से) कोड है
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
जब छवियों के चारों ओर काली सीमाएं अवांछनीय हैं, तो 'axicon.set_xticks ([]) 'और' axicon.set_yticks ([]) 'आदेश 'axicon.axis ('off') द्वारा प्रतिस्थापित किया जा सकता है। –
संबंधित मुद्दे
- 1. matplotlib/पायथन
- 2. पायथन: Matplotlib
- 3. matplotlib/पायथन
- 4. पायथन matplotlib: आकृति आकार
- 5. पायथन matplotlib ढांचे?
- 6. पायथन matplotlib एकाधिक सलाखों
- 7. पायथन 2.7 matplotlib
- 8. पायथन और matplotlib
- 9. पायथन matplotlib imshow() कस्टम टिकटें
- 10. matplotlib
- 11. matplotlib
- 12. Matplotlib
- 13. पायथन matplotlib - contour साजिश - आत्मविश्वास अंतराल
- 14. डेटाटाइम का प्लॉट हिस्टोग्राम। टाइम पायथन/matplotlib
- 15. (पायथन) matplotlib pyplot show() .. अवरुद्ध या नहीं?
- 16. Matplotlib पायथन शो() तुरंत लौटता है
- 17. पायथन matplotlib पूर्णांक टिक स्थानों तक सीमित
- 18. पायथन matplotlib डैश-डॉट-डॉट - कैसे करें?
- 19. 3 डी के लिए imshow? (पायथन/Matplotlib)
- 20. matplotlib
- 21. matplotlib
- 22. matplotlib
- 23. matplotlib
- 24. matplotlib
- 25. Matplotlib
- 26. matplotlib
- 27. matplotlib
- 28. matplotlib
- 29. matplotlib
- 30. matplotlib
करता है किसी को पता है कि यह 3 डी में काम करता है? क्या हम एक विमान में एक तस्वीर जोड़ सकते हैं? – CromeX
@ क्रोमएक्स: कृपया एक अलग प्रश्न पूछें। – tom10
लिंक अब और काम नहीं कर रहे हैं। –