How can I change the last marker of a line to a different style?
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have a plot where I want to change the last data point to a different marker style and marker size. In the plot below, I want the first 6 markers to be '*', and the last marker to be 'x'.
x = [0 7500 15000 22500 30000 36215 42433];
y = [114.8 112.4 105.5 103.4 103.6 101.9 91.8];
plot(x,y,'-*')
xlim([0 45000])
ylim([80 125])
xlabel('x')
ylabel('y')
grid on

0 Commenti
Risposta accettata
Arif Hoq
il 4 Feb 2022
x = [0 7500 15000 22500 30000 36215 42433];
y = [114.8 112.4 105.5 103.4 103.6 101.9 91.8];
plot(x,y,'-o','MarkerIndices',1:6)
hold on
plot(x,y,'-x','MarkerIndices',7)
xlim([0 45000])
ylim([80 125])
xlabel('x')
ylabel('y')
grid on
2 Commenti
Più risposte (2)
Davide Masiello
il 4 Feb 2022
x = [0 7500 15000 22500 30000 36215 42433];
y = [114.8 112.4 105.5 103.4 103.6 101.9 91.8];
plot(x(1:end-1),y(1:end-1),'-b*',x(end-1:end),y(end-1:end),'-b')
hold on
plot(x(end),y(end),'-bx','MarkerSize',12)
xlim([0 45000])
ylim([80 125])
xlabel('x')
ylabel('y')
grid on

0 Commenti
Vedere anche
Categorie
Scopri di più su Legend 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!

