[問題]legend的title問題(不是整個圖的title喔)

看板MATLAB作者 (noisenose)時間7年前 (2016/08/07 12:37), 7年前編輯推噓4(408)
留言12則, 6人參與, 最新討論串1/1
我是R2014b 想要打legend的title(不是整個圖的title喔) 但 使用matlab官網上範例 x = -pi:pi/20:pi; y1 = sin(x); y2 = cos(x); plot(x,y1,x,y2) l = legend('sin(x)','cos(x)'); title(l,'My Legend Title') 出現 Error using title (line 27) Incorrect number of input arguments Error in filename (line 6) title(l,'My Legend Title') 使用網路上另一法 x = -pi:pi/20:pi; y1 = sin(x); y2 = cos(x); plot(x,y1,x,y2) l = legend('sin(x)','cos(x)'); v = get(l,'title'); set(v,'string','Legend Title'); 出現 Error using matlab.graphics.illustration.Legend/get There is no title property on the Legend class. Error in filename (line 6) v = get(l,'title'); 新手上路 搞不太清楚問題出在哪裡 麻煩版上先進指點 非常感謝! -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 1.160.122.85 ※ 文章網址: https://www.ptt.cc/bbs/MATLAB/M.1470544637.A.16A.html ※ 編輯: noisenose (1.160.122.85), 08/07/2016 13:09:48

08/07 14:05, , 1F
試試看這樣?
08/07 14:05, 1F

08/07 14:05, , 2F
figure
08/07 14:05, 2F

08/07 14:05, , 3F
plot(what)
08/07 14:05, 3F

08/07 14:05, , 4F
title('name')
08/07 14:05, 4F

08/07 14:06, , 5F
如果只是想加標題在圖上的話
08/07 14:06, 5F

08/07 17:14, , 6F
例一title括弧中的 l 拿掉即可。即title('My Legend Title')
08/07 17:14, 6F

08/07 19:54, , 7F
痾...legend的title跟一般的title是有啥不同?
08/07 19:54, 7F
※ 編輯: noisenose (1.160.122.85), 08/07/2016 20:07:11 ※ 編輯: noisenose (1.160.122.85), 08/07/2016 20:08:18

08/07 21:10, , 8F
這篇可解? https://goo.gl/bQXMnb
08/07 21:10, 8F

08/07 21:11, , 9F
不過簡單一點應該用text或annotation就可以加字了
08/07 21:11, 9F

08/08 17:41, , 10F
樓上大大那連結就是我寫的二法ㄟ QQ 有其他法嗎
08/08 17:41, 10F

08/09 06:53, , 11F
官網上的說明檔是最新版本的,你應該用程式內的doc比較
08/09 06:53, 11F

08/09 06:53, , 12F
08/09 06:53, 12F
文章代碼(AID): #1Nfhhz5g (MATLAB)