필터 지우기
필터 지우기

how to start my plot from start of axis

조회 수: 2 (최근 30일)
hadiqa khan
hadiqa khan 2018년 7월 13일
편집: dpb 2018년 7월 14일
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)

답변 (1개)

dpb
dpb 2018년 7월 13일
편집: dpb 2018년 7월 14일
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().

카테고리

Help CenterFile Exchange에서 Discrete Data Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by