[問題]該如何依序點對點畫箭頭

看板R_Language作者 (empireisme)時間5年前 (2020/04/02 06:11), 5年前編輯推噓0(003)
留言3則, 3人參與, 5年前最新討論串1/1
最近在實作梯度下降 想要畫出overshooting https://imgur.com/S8JZMjp
以下是我的過程 x=seq(-3,3,0.01) plot( x,x^2 ,type = "l" ,xlab = "x",ylab = "f(x)" ) R=10 #eta is learning rate eta <- 2 #intail guess of x intail_x <- -3 # objective function f <- function(x) {x^2} # partial objective function partialf <-function(x) {2*x} x=numeric(length=(R+1)) x[1] <-intail_x for(i in 1:R){ x[i+1] <- x[i]-eta*partialf(x[i]) } data.frame(x,y=f(x)) 我有以下的點座標 https://imgur.com/JDxy3oK
想要畫出跟教科書一樣的圖 就是第一個點射到第二個點 第二個點在射到第三個點 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 219.91.75.186 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/R_Language/M.1585779113.A.B80.html

04/02 14:14, 5年前 , 1F
Segment 這函數可以看看 他是畫 p1到p2的線
04/02 14:14, 1F

04/02 14:29, 5年前 , 2F
請參考前面幾篇有人問plotly動圖
04/02 14:29, 2F

04/02 14:38, 5年前 , 3F
這可以不用動圖畫啊
04/02 14:38, 3F
謝謝,後來用arrow解決了 ※ 編輯: empireisme (101.12.53.3 臺灣), 04/02/2020 21:00:55
文章代碼(AID): #1UXH6fk0 (R_Language)
文章代碼(AID): #1UXH6fk0 (R_Language)