modify XY axises of 2 graphs in one figure

1 次查看(过去 30 天)
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