看板 R_Language 關於我們 聯絡資訊
[問題類型]: 程式諮詢(單純想了解contour如何使用> <) [軟體熟悉度]: 入門(寫過其他程式,只是對語法不熟悉) [問題敘述]: contour是繪製等高線圖的function 我看範例 需要 x,y,z 座標 所以輸入 > contour(10,20,200) 但是出現 Error in contour.default(10, 20, 200) : no proper 'z' matrix specified 那如果我用 > a<-matrix(1,10,10) >a[4,6]<-0 > contour(a) 則可以跑出下面圖片 http://imgur.com/X5tUgP7 問題來了 1.matrix(1,10,10) 不是 10*10 裡面都1的矩陣嗎 那麼它的z在哪裡? 2.contour(10,20,200) 出現錯誤訊息 是錯在哪裡 3.若我直接 contour(matrix(1,10,10)) 則會出現 整張白的... 為什麼咧~? *我沒有學過等高線圖 之類的 如果有理解錯誤 請大大鞭小力一點 謝謝 [環境敘述]: R version 3.3.3 (2017-03-06) Platform: i386-w64-mingw32/i386 (32-bit) Running under: Windows 8.1 x64 (build 9600) locale: [1] LC_COLLATE=Chinese (Traditional)_Taiwan.950 [2] LC_CTYPE=Chinese (Traditional)_Taiwan.950 [3] LC_MONETARY=Chinese (Traditional)_Taiwan.950 [4] LC_NUMERIC=C [5] LC_TIME=Chinese (Traditional)_Taiwan.950 attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] tools_3.3.3 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.229.106.117 ※ 文章網址: https://www.ptt.cc/bbs/R_Language/M.1492262738.A.A0A.html ※ 編輯: zcyee (36.229.106.117), 04/15/2017 21:26:42
celestialgod: 你有先看過example嗎 04/15 21:38
celestialgod: 沒有輸入x, y 預設x = 1:nrow(z), y = 1:ncol(z) 04/15 21:38
celestialgod: 只有一個input而且是matrix就會當成z 04/15 21:39
celestialgod: 第二個跟第三個推文 應該相反過來QQ 04/15 21:39
celestialgod: 有輸入x, y,第三個input一定要matrix 04/15 21:39
celestialgod: 這部分manual都有寫: 04/15 21:40
celestialgod: Note that x can be used instead of z for conveni 04/15 21:40
celestialgod: ence. 04/15 21:41
謝謝
zcyee: 所以 我的contour(10,20,200) 裡面的數字不是分別代表 x,y, 04/15 22:50
zcyee: z嗎 04/15 22:50
※ 編輯: zcyee (36.229.106.117), 04/15/2017 22:51:30
zcyee: 我要先宣告好x,y和 z矩陣。是這樣子嗎? 04/15 22:52
celestialgod: 你好像完全沒聽懂Orz 04/15 23:26
celestialgod: 程式會根據你的輸入去決定x,y,z 04/15 23:27
celestialgod: 當你只給一個input,而且是matrix的時候就會當成z 04/15 23:27
celestialgod: 其他情況就要給足x,y,z 04/15 23:27
celestialgod: 裡面只有z是要求是矩陣,x,y則無 04/15 23:28
哦 如果沒給xy的話預設是1 只有一個矩陣的話就是z嗎~? ※ 編輯: zcyee (36.229.106.117), 04/15/2017 23:47:01
celestialgod: 恩 04/16 00:28
謝謝~ ※ 編輯: zcyee (36.229.106.117), 04/16/2017 00:33:26