Mirror bar chart: 2 bar charts, 2 y axes, 1 x axis. Is it possible?

Hi all!
I want to get this mirror bar chart. Tried everything but nothing works.
Any idea?

6 件のコメント

VBBV
VBBV 2020 年 10 月 2 日
For the lower figure do
% if true
% code
% end
h= axes
bar(...)
set(h,'Ydir','reverse');
Jose Rego Terol
Jose Rego Terol 2020 年 10 月 2 日
編集済み: Jose Rego Terol 2020 年 10 月 2 日
This is exactly what I did in order to get the reverse bar.
Now, if you want to plot this reversed data set in the same plot of the other, sharing the x-axis, I got this plot:
Note that the 'normal' bar plot dissapeared.
a = (1:10)';
b = rand(10, 1);
c = rand(10, 1)*2;
figure
bar(a,b)
h1=axes
bar(a,b)
set(h1, 'Ydir', 'reverse')
Jose Rego Terol
Jose Rego Terol 2020 年 10 月 2 日
Look, this is the script for each plot
a = (1:10)';
b = rand(10, 1);
c = rand(10, 1)*2;
figure(1)
bar(a,b)
figure(2)
h1=axes
bar(a,c)
set(h1, 'Ydir', 'reverse')
The plots:
How can I 'merge' the plot using the same x-axis?
Jose Rego Terol
Jose Rego Terol 2020 年 10 月 2 日
Let´s be straight.
I want to get this bar plot
VBBV
VBBV 2020 年 10 月 2 日
%if true
% code
% end
a = (1:10)';
b = rand(10, 1);
c = rand(10, 1)*0.75;
figure
h1 = axes
bar(a,b);set(h1,'Ydir','normal'); hold(h1,'on')
h2 = gca
bar(a,-c)
set(h2, 'Ydir', 'reverse')
axis([0 10 -1 1])
Jose Rego Terol
Jose Rego Terol 2020 年 10 月 3 日
編集済み: Jose Rego Terol 2020 年 10 月 3 日
The y axis is negative. I need the y axis in positive integers.

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

回答 (1 件)

Jose Rego Terol
Jose Rego Terol 2020 年 10 月 2 日

1 投票

Nearly done
figure
ax1 = axes('Position',[0.138095238095238 0.529474812433012 0.791904761904761 0.400525187566988]);
bar(ax1,a,c)
box off
ax2 = axes('Position',[0.138095238095238 0.142857142857143 0.791904761904763 0.386617669575869]);
bar(ax2,a,b)
box off
set (ax2, 'ydir', 'reverse')

カテゴリ

ヘルプ センター および File ExchangeGraphics Object Properties についてさらに検索

質問済み:

2020 年 10 月 2 日

編集済み:

2020 年 10 月 3 日

Community Treasure Hunt

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

Start Hunting!

Translated by