필터 지우기
필터 지우기

Insert image behind graph

조회 수: 89 (최근 30일)
Ogen
Ogen 2016년 2월 12일
댓글: Andy Keane 2016년 3월 22일
Hi All. I am attempting to insert an image of a location on a map behind a graph on MatLAB. Any help would be greatly welcomed. Thanks
  댓글 수: 1
Andy Keane
Andy Keane 2016년 3월 22일
Have you tried emailing me?

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

채택된 답변

Mike Garrity
Mike Garrity 2016년 2월 12일
You can use hold to combine two things in the same axes. And you can set the XData & YData of an image to position.
Combining these two things would look something like this:
img = imread('ngc6543a.jpg');
theta = linspace(0,4*pi,200);
image('CData',img,'XData',[4 8],'YData',[-1/4 1/4])
hold on
plot(theta,sin(theta)./theta,'LineWidth',3)
hold off
A couple of things to look out for.
Order matters a lot here. If you do the image after the plot, you won't be able to see the plot because it will go behind the image. You can use the uistack function to fix this, but it's usually easier to just create them in the correct order.
The image function behaves differently depending on whether you set CData (as I did above) or just pass the data in like this:
image(img,'XData',[4 8],'YData',[-1/4 1/4])
When you call image this way, it's going to set a bunch of properties on the axes such as YDir and the limits. You can override all of those, but you'll probably find it simpler to use the CData form when you're doing this sort of thing.
  댓글 수: 1
Ogen
Ogen 2016년 2월 14일
Sorry for the delayed reply. I like the look of that graph, thanks for the help. Do you know if its possible to do geo-tagging. I want a picture of a map to appear behind the graph so would it be possible for the user to select an inputted location and that map to appear? Thanks again

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

추가 답변 (0개)

태그

Community Treasure Hunt

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

Start Hunting!

Translated by