Problematic categorical inputs when using line or scatter plot
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Scott Callahan
am 20 Nov. 2018
Kommentiert: Scott Callahan
am 20 Nov. 2018
Hi
I'm having trouble getting the last group in my scatter/line plot (100-109) going to the last spot chronologically like it should be. My code is:
Age = {'0-9';'1-19';'20-29';'30-39';'40-49';'50-59';'60-69';'70-79';'80-89';'90-99';'100-109'};
age=categorical(Age)
line(age,HumanPopDataThursF183.VarName4,'Marker','o')
and the last group in the data set somehow becomes the third point on the graph:

0 Kommentare
Akzeptierte Antwort
Cris LaPierre
am 20 Nov. 2018
Categorical values on the axis are ordered by the ruler Categorical property. To override this, use the following code:
line(Age,rand(1,length(Age)),'Marker','o');
ax = gca;
ax.XAxis.Categories = Age;
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Scatter Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!