Filter löschen
Filter löschen

how to start my plot from start of axis

1 Ansicht (letzte 30 Tage)
hadiqa khan
hadiqa khan am 13 Jul. 2018
Bearbeitet: dpb am 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)

Antworten (1)

dpb
dpb am 13 Jul. 2018
Bearbeitet: dpb am 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().

Kategorien

Mehr zu Discrete Data Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by