Hi.
I have coded the following for two scatters of measured values:
Plot2 = figure;
PV_TA2 = axes('Parent',Plot2);
hold(PV_TA2,'all');
scatter(T,I_K,'r', 'filled');
hold on
scatter(T,U_L,'g', 'filled');
xlabel('Temperatur in °C');
ylabel('Leerlaufspannung in mV | Kurzschlussstrom in mA');
title('Temperaturabhängigkeit','FontSize',14);
legend(Plot2,'I_K','U_L','Location','Best');
%Trend line
Poly2 = polyfit(T,U_L,1);
Poly3 = polyfit(T,I_K,1);
Trend2 = polyval(Poly2,T);
Trend3 = polyval(Poly3,T);
hold on
plot(T,Trend2, 'k', 'LineWidth', 1.5);
hold on
plot(T,Trend3, 'k', 'LineWidth', 1.5);
But the legend won't appear, so there must be something wrong.
How can I add a legend to my scatter. It should show a red dot or square depicting the short circuit current and a green one showing the open-circuit voltage.
Thanks for any hints!

 採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 11 月 9 日

1 投票

legend('I_K','U_L','Location','Best');

7 件のコメント

Marc Jakobi
Marc Jakobi 2013 年 11 月 9 日
Thank you! How can I add text to each value?
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 11 月 9 日
編集済み: Azzi Abdelmalek 2013 年 11 月 9 日
What do you mean? and where to add text?
Marc Jakobi
Marc Jakobi 2013 年 11 月 9 日
Well the legend gives me a red dot with the string 'Ik' and a green one with the string 'Uk' behind it. I would like to change those strings to 'short circuit current' and 'open-circuit voltage'
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 11 月 9 日
This is not clear
Marc Jakobi
Marc Jakobi 2013 年 11 月 9 日
I am trying to do something like this:
legend('I_K', 'String', 'short-circuit current', 'U_L', 'String', ...
'open-circuit voltage','Location','Best');
I_K is a vector of measured short-circuit currents that change depending on the temperature and U_L are the open-circuit voltages that also change.
The legend I currently have on my scattter looks like this:
%red dot% 'Ik'
%green dot% 'UL'
I would like to change it to:
%red dot% 'short-circuit current'
%green dot% 'open-circuit voltage'
(with %dot% I mean a picture of a dot)
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 11 月 9 日
編集済み: Azzi Abdelmalek 2013 年 11 月 9 日
I'am not following you. If I've understood, you want just to replace the legend
legend('short-circuit current', 'open-circuit voltage','Location','Best');
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 11 月 9 日
Marc commented
Oh, now I understand it. I misunderstood the way the legend function works. I thought you had to use legend('I_K', 'U_L', 'Location', 'Best') with I_K and U_L referring to the vectors U_L and I_K that were scattered. I did not realize that the order of the strings determines which one refers to which variable.
Thanks for your help!

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

その他の回答 (1 件)

Tony Castillo
Tony Castillo 2023 年 7 月 26 日

0 投票

Dear all,
I am having issues meanwhile I attempt adding legend to my SCATTER figure, I use this line of code legend ({'k1_{Winter}', 'k2_{Fall}', 'k3_{Summer}', 'k4_{Spring}'},'Location','Best') but only print the first one, how to solve this?
Sincerely

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by