필터 지우기
필터 지우기

Bar and Plot together, with Two Y axis

조회 수: 3 (최근 30일)
Rakibul Islam Rony
Rakibul Islam Rony 2017년 12월 15일
댓글: YT 2017년 12월 16일
Hi,
I am trying to make a figure with Bar and Plot together, with Two Y axis. I am using 2015a, so "yyaxis" does not work. Other solutions are also not working as the Bar plot is 2*6 matrix.
I want to add another y axis, so the bar plot does not look so small. I am using the below code, please help!!
Result = [2:3; 2:3; 2:3; 2:3; 2:3; 2:3; 2:3];
EE = [100:105];
EX = [55:60];
figure('Name','Test');
bar (Result)
hold on
plot (EE, '*')
hold on
plot (EX, 'o')

채택된 답변

YT
YT 2017년 12월 15일
While your code was not the same as the figure you provided (you missed plot(EX,'o') in the provided code), I managed to get the following figure
the code:
clear all;
close all;
Result = [2:3; 2:3; 2:3; 2:3; 2:3; 2:3; 2:3];
EE = 100:105;
EX = 55:60;
figure('Name','Test');
bar(Result);
ax1 = gca; % current axes
ax1_pos = ax1.Position; % position of first axes
ax2 = axes('Position',ax1_pos,...
'YAxisLocation','right',...
'Color','none',...
'XTickLabel','',...
'YTick','');
line(1:size(EE',1),EE','Parent',ax2,'Color','b','LineStyle','none','Marker','*')
line(1:size(EX',1),EX','Parent',ax2,'Color','r','LineStyle','none','Marker','o')
set(gca,'ytick',ax2.YLim(1):(ax2.YLim(2)-ax2.YLim(1))/5:ax2.YLim(2))
  댓글 수: 2
Rakibul Islam Rony
Rakibul Islam Rony 2017년 12월 15일
Thank you very much. btw, i did not miss the last line, i posted the .jpg figure before that.. So you can see the last line below the figure :P Thanks you so much again.
YT
YT 2017년 12월 16일
Oh well, my bad. Good luck with your project.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Printing and Saving에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by