Stacked bar plot for negative ambient .

8 visualizaciones (últimos 30 días)
Anil
Anil el 13 de Ag. de 2025
Comentada: Adam Danz el 3 de Nov. de 2025 a las 16:53
I have the components simulation data at -30C and steady bias , maneuver rise and margin (calculeted from given Tmax of each compoenent) to be plotted in stacked bar format ,
in the positive ambient the plots works fine but in negative ambient , the steady bias is starting from 0 (lets say @-30C , component setad bais is 6C , then it should start from -24C ?. see attched image .
please suggest the better ways to handle .
Thank you .
  2 comentarios
Chuguang Pan
Chuguang Pan el 13 de Ag. de 2025
bar function with BaseValue option may be effective
dpb
dpb el 13 de Ag. de 2025
@Anil it would be helpful to have the data
If the baseline for each bar is the same, then the suggestion of @Chuguang Pan should work for you straightforwardly.
But, the 'BaseValue' is one value for the whole plot, not on a bar-by-bar basis, so in that case you may have to get creative and either draw each bar individually with its own baseline value (I've not ever tried this) or rescale the data to be positive and then manually set the axes tick values to the desired values.
If the latter is the case, it would be most helpful to have the data and a more complete description of just how you would want the plot to look.

Iniciar sesión para comentar.

Respuestas (1)

Cris LaPierre
Cris LaPierre el 13 de Ag. de 2025
Movida: Cris LaPierre el 16 de Ag. de 2025
It would be helpful to see the code you used to create the plot. It appears that Tamb has been set to -30, so when creating a stacked bar chart, the first level is the same for all bars - a bar that goes from -30 to 0.
Tamb = -30*ones(5,1);
Bias = randi(20,[5,1]);
Rise = randi(40,[5,1]);
Margin = randi(200,[5,1]);
bar([Tamb Bias Rise Margin],'stacked')
legend("Tamb","Steady Bias","Maneuver Rise","Margin")
ylabel('Temperature')
Not exacty sure what you want, but using a bar to indicate Tamb doesn't seem right. Setting the BaseValue doesn't quite do what I would expect. Here's what I could come up with.
Tamb = -30;
bar([Bias Rise Margin],'stacked')
legend("Steady Bias","Maneuver Rise","Margin")
ylabel('Temperature')
yticklabels(Tamb+yticks)
  3 comentarios
Cris LaPierre
Cris LaPierre el 16 de Ag. de 2025
@Adam Danz any thoughts on this one?
Adam Danz
Adam Danz el 3 de Nov. de 2025 a las 16:53
Just catching up here. The OP's goal and problem isn't clear to me -- I wonder if Cris' solution solved it.

Iniciar sesión para comentar.

Categorías

Más información sobre Title 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