您可以通過手動留出線條的手柄,你不想成爲傳說離開了傳奇條目。試試這個:
%if you plot something, that you want showing up in the legend, save its handle:
h_line = plot(x,y)
%you dont want to show up this line? dont do anything, just plot it:
plot(myMarker)
%then set the legend-> you can add the text for your legend-entries with
%a cell-array containing the strings you want to show up:
legend([h_line another_line],{'Text1' 'Text2'})
與例子(見註釋),我來到了這個解決方案:
close all
X=[1:10];
Y=X*0.5+0.1;
ft = fittype('poly2');
f = fit(X', Y',ft);
ha=plot(f)
hold on
hc=plot(X,Y)
hb=errorbar(X, Y, X*0.1, 'squarek','MarkerFaceColor','k','markersize',5)
hleg1 = legend([ha hc],{'hnh','ghg'});
- >這只是折中一下劇情命令。希望可以幫助...
的結果應該是這樣的:
![enter image description here](https://i.stack.imgur.com/gBXc5.png)
我已經試過了。問題是,當我繪製出適合的線時,我同時得到紅線和藍點。我想在我的陰謀裏有黑色標記和紅線。如果我想命名給出適合線的情節,那麼藍點也將在那裏。 – Djamillah
你能顯示劇情指令嗎?那麼我可以重現它... –
%生成擬合線: ft = fittype('exp1'); f = fit(X',Y',ft); 情節(F,X,Y) errorbar(X,Y,錯誤 'squarek', 'MarkerFaceColor', 'K', 'markersize',5) hleg1 =圖例( '霍夫', 'HNH' , '溫室氣體'); – Djamillah