x data sorting in stem plot
Ältere Kommentare anzeigen
How can I keep the same x data sorting (categorical array) in a stem plot?
4 Kommentare
darova
am 26 Mai 2020
Please explain more, attach the code. Show some pictures
Manuel Di Luigi
am 26 Mai 2020
darova
am 26 Mai 2020
Try manually change xticklabel
h = stem(...);
set(h,'xticklabel',[1 2 3])
Manuel Di Luigi
am 26 Mai 2020
Antworten (1)
Cris LaPierre
am 26 Mai 2020
Bearbeitet: Cris LaPierre
am 26 Mai 2020
By default, Categoricals are organized in alphanumeric order. If you want to impose your own order on them, use the reordercats function. Since we don't have your code or files, here's a simple example using the months of the year.
month = ["January","February","March","April","May","June","July","August","September","October","November","December"];
m = categorical(month);
% Show order of categories (alpha-numeric)
categories(m)
ans = 12×1 cell array
'April'
'August'
'December'
'February'
'January'
'July'
'June'
'March'
'May'
'November'
'October'
'September'
m = reordercats(m,month);
% Show updated order of categories (imposed order)
categories(m)
ans = 12×1 cell array
'January'
'February'
'March'
'April'
'May'
'June'
'July'
'August'
'September'
'October'
'November'
'December'
Kategorien
Mehr zu Shifting and Sorting Matrices finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
