modify XY axises of 2 graphs in one figure
1 view (last 30 days)
Show older comments
Minh Phuong Truong
on 10 Feb 2022
Commented: Ankit
on 11 Feb 2022
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 Comments
dpb
on 10 Feb 2022
@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.
Accepted Answer
More Answers (1)
dpb
on 10 Feb 2022
"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 Comment
Adam Danz
on 10 Feb 2022
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.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!