How to tick a categorical x-axis in errobar plot

3 Ansichten (letzte 30 Tage)
Oliver Steiner
Oliver Steiner am 1 Nov. 2022
Beantwortet: MarKf am 1 Nov. 2022
I have this errorbar with categorical values on the x-axis. I want them in the order like I defined them at "n" but in the plot they are displayed in a different order. Does someone has an idea what to do?
vector_time_correct = [avg_Cortimeminusoutofprep avg_Cortimeminus200 avg_Cortimeminus150 avg_Cortimeminus100 avg_Cortimeminus50]
n = ["out of preparation","-200","-150","-100","-50"]
vector_time = categorical(n)
error_time_vector = [stderror_Cortimeminusoutofprep stderror_Cortimeminus200 stderror_Cortimeminus150 stderror_Cortimeminus100 stderror_Cortimeminus50]
plot(vector_time,vector_time_correct,'-b','LineWidth',3)
hold on
e = errorbar(vector_time,vector_time_correct,error_time_vector,'LineStyle','none','Color','b','CapSize',0,'linewidth',00.1)
hold off

Akzeptierte Antwort

MarKf
MarKf am 1 Nov. 2022
Categoricals are sorted and have an associated order by default that you need to override.
n = ["out of preparation","-200","-150","-100","-50"];
vector_time = categorical(n);
vector_time = reordercats(vector_time,n);

Weitere Antworten (0)

Kategorien

Mehr zu Errorbars 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!

Translated by