Stacked bar plot for negative ambient .

8 ビュー (過去 30 日間)
Anil
Anil 2025 年 8 月 13 日
コメント済み: Adam Danz 2025 年 11 月 3 日 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 件のコメント
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 約8時間 前
Just catching up here. The OP's goal and problem isn't clear to me -- I wonder if Cris' solution solved it.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeTitle についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by