# Plot Three Variables with Three separate Y axis

6 views (last 30 days)
Patrick Lonergan on 3 Aug 2021
Answered: Bjorn Gustavsson on 3 Aug 2021
Hi I am trying to plot three vairables on one graph. I am currently plotting it two seperate graphs and comparing but it would be really useful if I could plot one graph with all three vairables. The code I am using to produce the two graphs is as below:
yyaxis left
y=plot(failure.RMS)
ylabel("RMS Error")
yyaxis right
y=plot(failure.RollingAverage)
ylabel("rate of change of Power(W/10min)(rolling 500)")
legend("RMS Error of ML prediction","Rate of change of Power")
legend("Location","northwest")
title("RMS Error and Rolling average rate Of Power Prior to failure")
saveas(y,"Rolling_RMS Error1_11",'jpg');
saveas(y,"Rolling_RMS Error1_11",'m');
clf
yyaxis left
y=plot(failure.RMS)
ylabel("RMS Error")
yyaxis right
y=plot(failure.RollingAvePower)
ylabel("rate of change of Power(KW)(rolling 500)")
legend("RMS Error of ML prediction","Rolling Power Average")
legend("Location","northwest")
title("RMS Error and Rolling average Power Prior to failure")
saveas(y,"Rolling_power Error1_11",'jpg');
saveas(y,"Rolling_power Error1_11",'m');

Bjorn Gustavsson on 3 Aug 2021
You might use the plotyyy function from the matlab file excange to do just that. Or any of the other functions that show up when searching for plotyyy: FEX: plotyyy.
HTH

### Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

R2021a

### Community Treasure Hunt

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

Start Hunting!