inserting image in plot?
조회 수: 6 (최근 30일)
이전 댓글 표시
Hello,
I want to include a small .png image in a plot. I've already been looking all over, and it seems
test=imread('image.png'); axes('position',[.5 .5 .1 .1]); imagesc(test);
could do it, but the problem is: whenever I want to continue plotting other things, they will also appear in that small square, but I want them to appear in the normal/surrounding plot. How can I switch back?
Or can you maybe suggest a better method for including a small icon?
Thank you, Ruben
댓글 수: 0
채택된 답변
Walter Roberson
2011년 4월 15일
You do not need to create a new axes. Instead, you can pass position arguments to imagesc() exactly the same way you can pass them to image()
imagesc([.5 .5], [.6 .6], test)
Note, though, that the above will not position in exactly the same place as the axes() case: the position for image() and imagesc() is the coordinates of the center of the corner pixels, not the outside edge of the corner pixels.
댓글 수: 3
Walter Roberson
2011년 4월 15일
To solve the first problem, use "hold on" before using imagesc()
The second issue merely makes clear an issue you already had: you are expecting the image to be rendered in _pixel_ coordinates, but the positioning you are giving for it is in _data_ coordinates or in _normalized_ coordinates. If you were to take your existing approach and were then to make the window bigger, you would find that the image cells started occupying multiple pixels. If you want your image to be rendered in pixel coordinates no matter what the size of the axes was, then you need to tell us what _algorithm_ you wish to use for placing the image relative to the other items.
추가 답변 (1개)
shehneela khanzada
2021년 3월 30일
2.9154 83.8437 91.7168 1 0 0 0
82.7907 83.3675 91.6299 1 0 0 0
82.6085 82.9131 91.5352 1 0 0 0
82.3719 82.4845 91.4385 1 0 0 0
82.101 82.0753 91.3428 1 0 0 0
81.8199 81.6731 91.2471 1 0 0 0
81.5328 81.2764 91.1455 1 0 0 0
81.24 80.8859 91.0371 1 0 0 0
80.9368 80.5148 90.8975 1 0 0 0
80.6091 80.2145 90.6787 1 0 0 0
80.2663 79.9273 90.4551 1 0 0 0
79.9291 79.6129 90.2617 1 0 0 0
79.5923 79.2962 90.0713 1 0 0 0
79.2554 78.9788 89.8818 1 0 0 0
78.9183 78.6611 89.6934 1 0 0 0
78.5809 78.3435 89.5059 1 0 0 0
78.2433 78.0268 89.3164 1 0 0 0
77.9021 77.7212 89.1182 1 0 0 0
77.5546 77.4545 88.877 1 0 0 0
77.2154 77.181 88.6318 1 0 0 0
76.8767 76.9094 88.3838 1 0 0 0
76.5381 76.6453 88.1279 1 0 0 0
76.191 76.393 87.8721 1 0 0 0
75.8651 76.2131 87.542 1 0 0 0
75.5752 76.0571 87.166 1 0 0 0
75.3015 75.9058 86.7764 1 0 0 0
75.0318 75.7579 86.3818 1 0 0 0
74.7627 75.614 85.9854 1 0 0 0
74.4916 75.4749 85.5889 1 0 0 0
74.2163 75.3425 85.1934 1 0 0 0
73.9335 75.2212 84.7988 1 0 0 0
73.6406 75.118 84.4072 1 0 0 0
73.3404 75.0338 84.0166 1 0 0 0
73.0351 74.9599 83.6279 1 0 0 0
72.7275 74.8857 83.2412 1 0 0 0
72.4202 74.8018 82.8555 1 0 0 0
72.112 74.7052 82.4736 1 0 0 0
71.7978 74.6012 82.0986 1 0 0 0
71.4783 74.4947 81.7295 1 0 0 0
71.1591 74.3849 81.3604 1 0 0 0
70.8438 74.2709 80.9893 1 0 0 0
70.5378 74.1515 80.6123 1 0 0 0
70.2467 74.0249 80.2256 1 0 0 0
69.9867 73.8859 79.8223 1 0 0 0
69.7621 73.728 79.4043 1 0 0 0
69.5742 73.55 78.9766 1 0 0 0
69.4151 73.3643 78.54 1 0 0 0
69.2711 73.1847 78.0967 1 0 0 0
69.1265 73.0256 77.6455 1 0 0 0
68.9736 72.895 77.1875 1 0 0 0
68.8209 72.7879 76.7236 1 0 0 0
68.6738 72.6971 76.2549 1 0 0 0
68.5325 72.6189 75.7813 1 0 0 0
68.3975 72.5498 75.3047 1 0 0 0
68.2702 72.4868 74.8252 1 0 0 0
68.1641 72.4376 74.3389 1 0 0 0
68.0807 72.4087 73.8467 1 0 0 0
67.9982 72.3902 73.3535 1 0 0 0
67.894 72.3692 72.8652 1 0 0 0
67.7633 72.3421 72.3838 1 0 0 0
67.616 72.3137 71.9072 1 0 0 0
67.4613 72.2853 71.4326 1 0 0 0
67.3029 72.2572 70.959 1 0 0 0
67.1424 72.2291 70.4863 1 0 0 0
66.9836 72.2035 70.0127 1 0 0 0
66.8451 72.1814 69.5332 1 0 0 0
66.7188 72.1567 69.0498 1 0 0 0
66.5928 72.1318 68.5664 1 0 0 0
66.4671 72.107 68.083 1 0 0 0
66.3413 72.0823 67.5996 1 0 0 0
66.2154 72.0578 67.1162 1 0 0 0
66.0892 72.0338 66.6328 1 0 0 0
65.9566 72.0169 66.1514 1 0 0 0
65.8001 72.0178 65.6768 1 0 0 0
65.6436 72.012 65.2021 1 0 0 0
65.4909 72.0321 64.7266 1 0 0 0
65.3436 72.1009 64.2549 1 0 0 0
65.2021 72.2047 63.7871 1 0 0 0
65.0735 72.3353 63.3223 1 0 0 0
65.1517 72.6034 63.0732 1 0 0 0
65.0145 72.5896 62.7754 1 0 0 0
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!