connect marker with lines
4 views (last 30 days)
Show older comments
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!
Accepted Answer
Image Analyst
on 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;
More Answers (1)
Rajeev
on 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)
Refer to the documentation for more: Create Line Plot with Markers - MATLAB & Simulink (mathworks.com)
0 Comments
See Also
Categories
Find more on ANOVA in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!