connect marker with lines

3 ビュー (過去 30 日間)
ANDREA
ANDREA 2023 年 1 月 25 日
コメント済み: ANDREA 2023 年 1 月 25 日
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 件のコメント
Jiri Hajek
Jiri Hajek 2023 年 1 月 25 日
This is readily done using the plot function properly. Please look at the plot documentation.

サインインしてコメントする。

採用された回答

Image Analyst
Image Analyst 2023 年 1 月 25 日
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;
  1 件のコメント
ANDREA
ANDREA 2023 年 1 月 25 日
thanks!

サインインしてコメントする。

その他の回答 (1 件)

Rajeev
Rajeev 2023 年 1 月 25 日
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)

カテゴリ

Help Center および File ExchangeLegend についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by