Remove the edge between two stacked bars

3 ビュー (過去 30 日間)
giannit
giannit 2020 年 7 月 24 日
編集済み: giannit 2020 年 7 月 24 日
Consider the following stacked bars
data = [2 1 ; 3 2];
b = bar(data,'stacked');
axis([0 3 0 6])
the plot I'd like to obtain is the one showed in the image below, that is stacked bars with all edges but the one between the bars.
I tried with `b(1).EdgeAlpha = 0` but this removes also the side edges of the blue bar.
A very naive (and ugly) approach is to remove all edges and then to plot a rectangle with the size of the two stacked bars
data = [2 1 ; 3 2];
bar(data,'stacked','EdgeAlpha',0);
hold on
axis([0 3 0 6])
syms x
fplot(rectangularPulse((x-1)*1.25)*sum(data(1,:)), [.6 1.4]+[-1 1]*1e-13,'k')
fplot(rectangularPulse((x-2)*1.25)*sum(data(2,:)), [1.6 2.4]+[-1 1]*1e-13,'k')
Is there a handy way using the bar properties or something else?

回答 (1 件)

KSSV
KSSV 2020 年 7 月 24 日
bar(data,'stacked','EdgeAlpha',0,'EdgeColor','none');
  1 件のコメント
giannit
giannit 2020 年 7 月 24 日
The plots generated by
bar(data,'stacked','EdgeAlpha',0,'EdgeColor','none')
and by
bar(data,'stacked','EdgeAlpha',0)
are the same and they have no edges at all, while I'd like to keep all edges but the one between the bars.

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

カテゴリ

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

タグ

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by