Filter löschen
Filter löschen

connect marker with lines

2 Ansichten (letzte 30 Tage)
ANDREA
ANDREA am 25 Jan. 2023
Kommentiert: ANDREA am 25 Jan. 2023
Hi all!
I have to connect these markers with one line, how can i do? My version of Matlab is 2014a.
The code is:
%plot
for i=1:18
figure(1)
title('Temperatura Max','fontsize',20)
xlabel('n° sensore','fontsize',15)
ylabel('Temperatura [°]','fontsize',15)
plot(i,Max_Temp20(1,i),'.','color',rgb('red'),'MarkerSize',20)
hold on
plot(i,Max_Temp30(1,i),'.','color',rgb('green'),'MarkerSize',20)
hold on
plot(i,Max_Temp50(1,i),'.','color',rgb('blue'),'MarkerSize',20)
hold on
plot(i,Max_Temp60(1,i),'.','color',rgb('pink'),'MarkerSize',20)
hold on
plot(i,Max_Temp70(1,i),'.','color',rgb('cyan'),'MarkerSize',20)
hold on
plot(i,Max_Temp80(1,i),'.','color',rgb('orange'),'MarkerSize',20)
hold on
plot(i,Max_Temp90(1,i),'.','color',rgb('black'),'MarkerSize',20)
hold on
grid on
legend('20% potenza','30% potenza','50% potenza','60% potenza','70% potenza','80% potenza','90% potenza')
end
Thank you!
  1 Kommentar
Jiri Hajek
Jiri Hajek am 25 Jan. 2023
This is readily done using the plot function properly. Please look at the plot documentation.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Image Analyst
Image Analyst am 25 Jan. 2023
You don't need all those hold on's, you just need one. Also don't use a for loop because that's plotting just one marker at a time and the plot function has no knowledge of what prior marker you want to connect the current one to. You need to plot a whole range of data at one time. I think this should work.
columnsToPlot = 1:18;
figure(1)
plot(i,Max_Temp20(1,columnsToPlot), '.-', 'Color',rgb('red'), 'MarkerSize',20)
hold on
plot(i,Max_Temp30(1,columnsToPlot), '.-', 'Color',rgb('green'), 'MarkerSize',20)
plot(i,Max_Temp50(1,columnsToPlot), '.-', 'Color',rgb('blue'), 'MarkerSize',20)
plot(i,Max_Temp60(1,columnsToPlot), '.-', 'Color',rgb('pink'), 'MarkerSize',20)
plot(i,Max_Temp70(1,columnsToPlot), '.-', 'Color',rgb('cyan'), 'MarkerSize',20)
plot(i,Max_Temp80(1,columnsToPlot), '.-', 'Color',rgb('orange'), 'MarkerSize',20)
plot(i,Max_Temp90(1,columnsToPlot), '.-', 'Color',rgb('black'), 'MarkerSize',20)
grid on
title('Temperatura Max','fontsize',20)
xlabel('n° sensore','fontsize',15)
ylabel('Temperatura [°]','fontsize',15)
legend('20% potenza','30% potenza','50% potenza','60% potenza','70% potenza','80% potenza','90% potenza')
hold off;

Weitere Antworten (1)

Rajeev
Rajeev am 25 Jan. 2023
You can use the '-' in front of the marker to join the points with a line. Example:
plot(i,Max_Temp30(1,i),'-o','MarkerFaceColor','green','MarkerSize',20)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by