How to tick a categorical x-axis in errobar plot

3 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

MarKf
MarKf il 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);

Più risposte (0)

Categorie

Scopri di più su Errorbars in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by