subplot question - with image and plot
조회 수: 9 (최근 30일)
이전 댓글 표시
I'm using a subplot but I want to use imshow(img) in one section of the subplot and want to simply 'plot()' something in another section. Does this work? Whatever examples I have seen on MATLAB pages is either all should have imshow or all should have plot. both don't work together it seems?!
댓글 수: 0
답변 (2개)
Tommy
2020년 5월 12일
This is possible by setting the parent axes in your call to imshow:
subplot(1,2,1);
plot(rand(10,1));
ax = subplot(1,2,2);
imshow('peppers.png', 'Parent', ax);
댓글 수: 2
Image Analyst
2020년 5월 12일
In that case, you don't even need to worry about Parent and ax -- it will show the image in the second subplot even without using them.
subplot(1,2,1);
plot(rand(10,1));
subplot(1,2,2);
imshow('peppers.png');
I do it all the time.
Tommy
2020년 5월 12일
Oh nice thanks for the tip! I shouldn't have assumed it would be needed.
Besides looks like I may have misinterpreted the Q, whoops.
Image Analyst
2020년 5월 12일
If you have a subplot and want to show both an image and a plot in the subplot, please see my attached inset demos.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/292329/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/292330/image.png)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Subplots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!