How to plot a plot that has multi coordinates in one x coordinate?

4 vues (au cours des 30 derniers jours)
juan sanchez
juan sanchez le 6 Oct 2021
Commenté : juan sanchez le 5 Nov 2021
How to plot a plot that has multi coordinates in one x coordinate? Please see attached image.

Réponse acceptée

Dave B
Dave B le 4 Nov 2021
Modifié(e) : Dave B le 4 Nov 2021
A good strategy for these kinds of plots is to treat it as if the numbers are 1 to 15, and then just change the labels
y=rand(1,15);
x=1:15;
scatter(x,y,'x')
set(gca,'XTick',1:15,'XTickLabels',1:3)
for i = 1:5
xline(i*3+.5,'Label',"ZONE " + i, 'LabelHorizontalAlignment', 'left')
end
box on
But you can also use tiledlayout effectively for this kind of thing by setting the TileSpacing property to 'none'
figure
t=tiledlayout(1,5,'TileSpacing','none');
for i = 1:5
scatter(nexttile,1:3,rand(1,3),'x')
ylabel("ZONE " + i) % you might want to use the text function for the labels...as this is awkward
box on
end
linkaxes(t.Children)
xlim([.5 3.5])
set(t.Children(1:4), 'YTickLabel', [])
xlabel(t,'Case Number')
  1 commentaire
juan sanchez
juan sanchez le 5 Nov 2021
Thank you very much, this was a very good plot and identical to the question.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Axes Appearance dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by