Stacked bar plot for negative ambient .

조회 수: 5 (최근 30일)
Anil
Anil 2025년 8월 13일
댓글: Adam Danz 2025년 11월 3일
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
Chuguang Pan
Chuguang Pan 2025년 8월 13일
bar function with BaseValue option may be effective
dpb
dpb 2025년 8월 13일
@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.

댓글을 달려면 로그인하십시오.

답변 (1개)

Cris LaPierre
Cris LaPierre 2025년 8월 13일
이동: Cris LaPierre 2025년 8월 16일
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
Cris LaPierre
Cris LaPierre 2025년 8월 16일
@Adam Danz any thoughts on this one?
Adam Danz
Adam Danz 2025년 11월 3일
Just catching up here. The OP's goal and problem isn't clear to me -- I wonder if Cris' solution solved it.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Title에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by