Plot different curves in cycle for

2 vues (au cours des 30 derniers jours)
Davide Bassignana
Davide Bassignana le 13 Avr 2017
Commenté : dbmn le 13 Avr 2017
I want to plot 3 different curves in the same graph (one parameter changing).
if true
for M0=1.5:0.5:2.5
disp('Valori scelti di Mi')
yyaxis left
grid minor
plot(Mi,Dad,'-^','LineWidth', 2,'MarkerSize',8);
ylabel('Resistenza addizionale','FontSize',14)
title('Resistenza addizionale presa Pitot subcritica','FontSize',16)
yyaxis right
ylabel('Coeff. di Portata','FontSize',14)
hold on
(ignore the first line if true).
Wath I want is to get this graph with every blu and orange line with different style operating inside the for command.

Réponse acceptée

dbmn le 13 Avr 2017
You where almost correct. Just 2 small corrections:
1) "hold on" You added this line at the end of the script - this wont help you. Think about hold on as only between the two lines hold on / hold off that function is active (even if you dont specify hold off) -> just add hold on earlier in your code
2) use plotyy instead of plot. This allows you to get plots with 2 y axes
3) try to use handles, f.ex. h1 = plot(...). This allows you to accees the plotted lines much easier later in your script
  3 commentaires
dbmn le 13 Avr 2017
ooops. Correction - i was to fast. Now it should work :) (tested)
plot(Mi,Dad,my_linestyle{i},'LineWidth', 2,'MarkerSize',8);

Connectez-vous pour commenter.

Plus de réponses (0)


En savoir plus sur Two y-axis dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by