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

10 Ansichten (letzte 30 Tage)
Jose Rego Terol
Jose Rego Terol am 2 Okt. 2020
Bearbeitet: Jose Rego Terol am 3 Okt. 2020
Hi all!
I want to get this mirror bar chart. Tried everything but nothing works.
Any idea?
  6 Kommentare
VBBV
VBBV am 2 Okt. 2020
%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 am 3 Okt. 2020
Bearbeitet: Jose Rego Terol am 3 Okt. 2020
The y axis is negative. I need the y axis in positive integers.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Jose Rego Terol
Jose Rego Terol am 2 Okt. 2020
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')

Kategorien

Mehr zu Creating, Deleting, and Querying Graphics Objects finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by