필터 지우기
필터 지우기

modify XY axises of 2 graphs in one figure

조회 수: 3 (최근 30일)
Minh Phuong Truong
Minh Phuong Truong 2022년 2월 10일
댓글: Ankit 2022년 2월 11일
I have 2 graphs, which want to plot in same figure. The first one is matrix, use imagesc to display. The second data is coast.mat, I would like to overlap the coastline on my 1st graph.
How can I adjust, X axis 0-313 (from matrix data) equal to 112.9292-125.9792 (from coast.mat) , similar with Y axis 0-409 (matrix data) = 10.02083-27.02083 (coast.mat)
Thanks
  댓글 수: 4
dpb
dpb 2022년 2월 10일
@Ankit -- NB there is only one x-axes and the blue values are constrained to be only in the middle of the plot, not correlated of min-max ranges of the two to overlay the second on the first. And the two y axes are completely noncomparable in magnitudes...not what OP is looking for here.
Ankit
Ankit 2022년 2월 11일
@dpb yes you are right... this will only plot two separate y axis...

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

채택된 답변

Minh Phuong Truong
Minh Phuong Truong 2022년 2월 11일
graph1 = ncread('D:\addfea'); %read graph 1 nc file data
C = load('coasts.mat'); %load the coasts.mat file to get the coast line data
%display graph1 which the X axis min value = 0 equal to 112.9292 (from coasts.mat)
%X axis max value = 313 equal to -125.9792 (from coasts.mat)
%Northern hemisphere, grahp1 displays upside down
%Y axis min value = 0 equal to 27.02083 (from coasts.mat)
%Y axis max value = 409 equal to 10.02083 (from coasts.mat)
imagesc([112.9792 125.9792],[27.02083 10.02083],grahp1);
%display coast line
plot(C.Lon,C.Lat,'k');

추가 답변 (1개)

dpb
dpb 2022년 2월 10일
"How can I adjust, X axis 0-313 (from matrix data) equal to 112.9292-125.9792 (from coast.mat) , similar with Y axis 0-409 (matrix data) = 10.02083-27.02083 (coast.mat)"
Use linear interpolation would be one way...
>> interp1([0 313],[112.9292 -125.9792],[0:50:313 313])
ans =
112.9292 74.7649 36.6006 -1.5636 -39.7279 -77.8922 -116.0565 -125.9792
>>
would give you a new x-axis vector with which to label the image -- or, probably more appropriate to your case would be to reverse and turn the map coordinates into image dimensions.
Alternatively, you can use the x,y coordinates optional inputs into imagesc itself; there you may have to fudge a little because the center of the displayed corner pixels are on the range values; with 3-400 pixels the rounding may not be off enough to worry about. See the doc for imagesc for the syntax and example use.
  댓글 수: 1
Adam Danz
Adam Danz 2022년 2월 10일
The problem might be that OP wants to overlay linear data (imagesc) on top of geoaxes which are nonlinear. I've run into this problem myself in the past in this answer --> option 3.
But it's unclear how OP is plotting the coastal data so this is just a foggy hunch.

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by