modify XY axises of 2 graphs in one figure
조회 수: 3 (최근 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
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.
채택된 답변
추가 답변 (1개)
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
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.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!