How to draw two plots in one figure?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Nazila Pourhajy
il 31 Mag 2022
Risposto: Abhijit Nayak
il 31 Mag 2022
Hi everyone.
I have two plots like this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1016820/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1016825/image.jpeg)
I want to have two plots in one figure like this in matlab. But I dont know what to do. please help me Thanks alot..
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1016830/image.jpeg)
When I use this commands:
plot(x,y1);
hold on;
plot(x,y2);
hold off;
The result is as follow:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1016870/image.jpeg)
Becaues the values of y in two plots are different.
0 Commenti
Risposta accettata
Più risposte (1)
Abhijit Nayak
il 31 Mag 2022
From my understanding, you are looking for a way to have two plots in one figure with a common x-axis. You can use “yyaxis” function for such scenario.
For further reference, you can refer to the following MATLAB documentation link- .
0 Commenti
Vedere anche
Categorie
Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!