Clear Filters
Clear Filters

how to start my plot from start of axis

2 views (last 30 days)
hadiqa khan
hadiqa khan on 13 Jul 2018
Edited: dpb on 14 Jul 2018
i want my graph to start from start of x axis but also the xticks to be zero at start of x axix and then increase
my code is
figure(25)
plot((SMed_eq),'-r','Marker','*','LineWidth',1.3);
hold on
plot((SMed_eq_ne),'-g','Marker','*','LineWidth',1.3);
set(gca,'FontSize', 15);
%ylim([200 1200]);
%xlim([0 23]);
set(gca,'XTICK',1:1:24,'XTickLabel',{'0','1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23'});
hold off
h=legend('OBS EQU MED','Ne EQU MED');
%annotation('textbox', [0 0.9 1 0.1],'String','SONM EQUINOX MED(OBS vs NeQuick)','EdgeColor', 'none','HorizontalAlignment', 'center','VerticalAlignment','top','FontWeight','bold','FontSize',12)
annotation('textarrow',[0.075 0.5],[0.6 0.9],'String','Slab Thickness(km)','HeadStyle','none','LineStyle', 'none','FontWeight','bold','FontSize',20, 'TextRotation',90);
annotation('textbox', [0.5 0 0 0.7],'String','LT(hrs)','EdgeColor', 'none','HorizontalAlignment', 'center' ,'VerticalAlignment','bottom','FontWeight','bold','FontSize',20)

Answers (1)

dpb
dpb on 13 Jul 2018
Edited: dpb on 14 Jul 2018
But you plotted against ordinal number of observation...
plot((SMed_eq),'-r','Marker','*','LineWidth',1.3);
hold on
plot((SMed_eq_ne),'-g','Marker','*','LineWidth',1.3);
Use
x=0:length(SMed_g)-1;
plot(x,SMed_eq,'-r','Marker','*','LineWidth',1.3);
etc., instead and you can then just set xlim limits to
xlim([0 UP])
where UP is whatever you want for visual effect as the upper x-axis limit. tick labels will match ticks and start at 0 for both with no machinations needed.
As is, you'd need to do something like
hAx=gca;
xtk=hAx.XTick;
hAx.XTickLabel=xtk-1;
but it's simpler to just use the desired x coordinates against which to plot().

Categories

Find more on Discrete Data Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!