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!

 Réponse acceptée

Syed Zeeshan
Syed Zeeshan le 18 Jan 2017

0 votes

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.

Plus de réponses (0)

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by