Borrar filtros
Borrar filtros

How to tick a categorical x-axis in errobar plot

2 visualizaciones (últimos 30 días)
Oliver Steiner
Oliver Steiner el 1 de Nov. de 2022
Respondida: MarKf el 1 de Nov. de 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

Respuesta aceptada

MarKf
MarKf el 1 de Nov. de 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);

Más respuestas (0)

Categorías

Más información sobre Data Distribution Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by