Data does not plot after setting XTick and XTick Label

I am trying to plot the data in the image such that the only Xaxis points that are shown are the ones that have a data point there. I find all the Xaxis point that have data and store them in an array called UniqueFreq.
UniqueFreq =
2012 2015 2018 2020 2023 1882 1885 1900 1915 1918
set(gca,'xtick',1:numel(unique(UniqueFreq)));
hold on
set(gca,'xticklabel',unique(UniqueFreq))
hold on
xlim([0 numel(unique(UniqueFreq))+1]);
hold on
ylim([(min(YLim) - 0.5) (max(YLim) + 0.5)]);
After I do the above I try to plot the data using:
plot(DataArray{i,8},DataArray{i,9},'-o');
hold on
Where the X value is always one of the values in the XTick, for example, a plot value would be: plot(2012,1.5); However when I do this nothing plots.
If anyone has any idea it would be really helpful.
Thanks!

 채택된 답변

Syed Zeeshan
Syed Zeeshan 2017년 1월 18일

0 개 추천

I found the problem.
The issue is with setting the xtick to 1:numel(UniqueFreq).
If I set xtick to the array UniqueFreq I am able to get the data to plot.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Annotations에 대해 자세히 알아보기

제품

질문:

2017년 1월 18일

답변:

2017년 1월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by