overplot contours on image

How can I overplot contours on an image? The image and the contours have different limits. I tried plotting the image using the bottom x-axis and left y-axis and the contrary for the contours. But it doesn't work.
My code:
imagesc(1:100,1:100,C)
ax1 = gca;
ax2 = axes('Position',get(ax1,'Position'),...
'XAxisLocation','top','YAxisLocation','right',...
'Color','none',...
'XColor','k','YColor','k');
contour(ax2,Z)
This only displays the contours. I am unable to see the image.
Can someone provide any assistance?

 채택된 답변

Angus
Angus 2013년 6월 19일

0 개 추천

Regardless of limits, you need to use 'hold on' before executing the contour function or it will always overwrite the image that is in the axis.
If you have tried this then let me know and ill look at it again. That was just what first jumped out at me :)

댓글 수: 5

Venkatessh
Venkatessh 2013년 6월 19일
Tried with the "hold on" option. Still only the contours are visible
Angus
Angus 2013년 6월 19일
Tried testing this and it seemed to work as you had desired when using 'hold on' before plotting the contours. I have 1 to 110 along the top and right while only 1 to 100 along the left and bottom. My image shows with contours overlaid.
Hope this simple fix works for you.
Angus
Angus 2013년 6월 19일
Strange, thats too bad. Okay what are you dimensions for 'C' and 'z'? What kind of data are they?
Venkatessh
Venkatessh 2013년 6월 19일
Placed the hold on at a wrong place. Now it works!
Thank you.
Angus
Angus 2013년 6월 19일
Great! Haha, I wasn't too sure where to go from there, glad that worked.
Cheers, Angus.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Contour Plots에 대해 자세히 알아보기

질문:

2013년 6월 19일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by