Plot bar with 2 different axis
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ali Tawfik
am 11 Sep. 2018
Bearbeitet: KALYAN ACHARJYA
am 12 Sep. 2018
Hello, I am new to Matlab.. I wanna to plot bar with 2 different y axis... I do not understand much functions, so can any one help me
4 Kommentare
KALYAN ACHARJYA
am 11 Sep. 2018
Bearbeitet: KALYAN ACHARJYA
am 11 Sep. 2018
If somehow I can help you, it would be great for me. I am using quite older version of Matlab, yyaxis was introduced in 2016a,have you tried as following, I have not tested it.
x=linspace(0,20);
y1=sin(x);
yyaxis left
bar(x,y)
y2=sin(2*x).*exp(0.5*x);
yyaxis right
bar(x,z)
Akzeptierte Antwort
KALYAN ACHARJYA
am 11 Sep. 2018
Bearbeitet: KALYAN ACHARJYA
am 12 Sep. 2018
With the help of same link, I have done this one. %Plot two signal y-axis with bar
x=0:.1:5;
y1=sin(x);
y2=cos(x);
figure,
[sig,sig1,sig2]=plotyy([1:length(y1)],y1,[1:length(y2)],y2,'bar','bar');
set(sig1,'FaceColor','r') ;
set(sig2,'FaceColor','b') ;
title('Two y axis Plot');
xlabel('Time')
ylabel(sig(1),'Sin') % left y-axis
ylabel(sig(2),'Cos') % right y-axis
Hope it would be helpful.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/195416/image.png)
4 Kommentare
KALYAN ACHARJYA
am 11 Sep. 2018
Bearbeitet: KALYAN ACHARJYA
am 11 Sep. 2018
Ali Tawfik, Can you share the code, which do you want to implement this?
KALYAN ACHARJYA
am 11 Sep. 2018
Bearbeitet: KALYAN ACHARJYA
am 12 Sep. 2018
I have edited the answer, now you can modify the code as per your requirements.
For any Help, mention in comment below.
Thanks
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Annotations 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!