Plot over a image

조회 수: 12 (최근 30일)
Vittorio Faustinella
Vittorio Faustinella 2021년 12월 4일
댓글: Vittorio Faustinella 2021년 12월 5일
Hello to all,
I've a question, i want plot a graphic over a image, I've write this code:
%Plot Sw - r^2/t
figure(1)
imshow('Image2011.jpg'),colormap jet
hold on
semilogx(s.Sim,s.S_w, 'k');
xlabel r^2/t(m^2/s)
ylabel Sw
xlim([0.0001, 1])
ylim([0,1])
hold off
but it doesn't work because the two graphs do not coincide. How can I do?
This is the image:

답변 (1개)

Walter Roberson
Walter Roberson 2021년 12월 4일
%Plot Sw - r^2/t
figure(1)
Image2011 = imread('Image2011.jpg');
image([0 1], [0 1], Image2011)
colormap jet
hold on
semilogx(s.Sim,s.S_w, 'k');
xlabel r^2/t(m^2/s)
ylabel Sw
xlim([0.0001, 1])
ylim([0,1])
hold off
Note that jpg images are almost always RGB images, so the colormap jet is probably not going to affect the display of the image. It might as there are some grayscale JPG images... they are just very very uncommon, with it being much more common that what looks like a grayscale JPG image is really an RGB image.
  댓글 수: 5
Walter Roberson
Walter Roberson 2021년 12월 5일
Hmmmm, there is a bit of a difficulty there. The plot in the image is in log scale, but you cannot use log scale with negative coordinates.
So you have two choices:
  1. Use two different axes with one overlaying the other, one with linear scale used to hold the image, and the other with log scale positioned a little to the right of the start of the other axes so that the 0.000001 point aligns with the image left hand side; OR
  2. use a single linear scale, but do a log transform of the x coordinates to determine linear coordinates to draw the data at; in such a case the image should probably be placed to have an x limit of 6
Vittorio Faustinella
Vittorio Faustinella 2021년 12월 5일
Thank you for your time, I'll figure it out.

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

카테고리

Help CenterFile Exchange에서 Visual Exploration에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by