How can I have two x-labels below x axis showing both LATITUDE and LONGITUDE points?

8 次查看(过去 30 天)
Both lat/lon spacing are equal and forms square grid boxes. I have another variable at y-axis.
I have attached one figure for illustration...

采纳的回答

Star Strider
Star Strider 2014-9-8
I don’t have your code or figure, so this is the best I can do:
x = linspace(0,10*pi,1000);
y = sin(2*pi*sin(x));
figure(1)
plot(x,y)
grid
axis tight
ymin = min(ylim);
yrng = diff(ylim);
xt = get(gca, 'XTick');
set(gca, 'XTickLabel', []);
nrxt = size(xt,2);
latvct = linspace(71.59, 24.06, nrxt);
lat_txt = cellstr(strsplit(num2str(latvct,'%.2f '),' '));
text([(xt(1)-xt(2))*0.5 xt], ones(1,nrxt+1)*ymin-0.05*yrng, ['Lat ' lat_txt],'HorizontalAlignment','center')
lngvct = linspace(100.71, 75.54, nrxt);
lng_txt = cellstr(strsplit(num2str(lngvct,'%.2f '),' '));
text([(xt(1)-xt(2))*0.5 xt], ones(1,nrxt+1)*ymin-0.1*yrng, ['Lon' lng_txt],'HorizontalAlignment','center')
Everything you likely need is here, but you will obviously have to experiment with it to get the result you want in your application.
It produces:
  4 个评论
Sreeraj T
Sreeraj T 2021-5-16
编辑:Sreeraj T 2021-5-16
@sachin patel, i am not sure you got the answer for the query. Anyway, this is mine. What I found is that the spacing is controlled by
ymin-0.05*yrng
and
ymin-0.12*yrng
You may change the numbers and see it for yourself. If you increase the second no. (i.e. 0.12) substantially, then the label may 'go outside the plot'.
Sreeraj T
Sreeraj T 2021-5-17
@Star Strider I am trying to understand this code. If i replace x by
log10(linspace(12.858000,690.02002,605)')
, then the texts 'Lat' and 'Lon' no longer appears. Why is that happening?

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by