我正在将我的情节移动到 ggplot 中。除了这个(代码来自上一个问题)之外几乎都存在:
#Set the bet sequence and the % lines
betseq <- 0:700 #0 to 700 bets
perlin <- 0.05 #Show the +/- 5% lines on the graph
#Define a function that plots the upper and lower % limit lines
dralim <- function(stax, endx, perlin) {
lines(stax:endx, qnorm(1-perlin)*sqrt((stax:endx)-stax))
lines(stax:endx, qnorm(perlin)*sqrt((stax:endx)-stax))
}
#Build the plot area and draw the vertical dashed lines
plot(betseq, rep(0, length(betseq)), type="l", ylim=c(-50, 50), main="", xlab="Trial Number", ylab="Cumulative Hits")
abline(h=0)
abline(v=35, lty="dashed") #Seg 1
abline(v=185, lty="dashed") #Seg 2
abline(v=385, lty="dashed") #Seg 3
abline(v=485, lty="dashed") #Seg 4
abline(v=585, lty="dashed") #Seg 5
#Draw the % limit lines that correspond to the vertical dashed lines by calling the
#new function dralim.
dralim(0, 35, perlin) #Seg 1
dralim(36, 185, perlin) #Seg 2
dralim(186, 385, perlin) #Seg 3
dralim(386, 485, perlin) #Seg 4
dralim(486, 585, perlin) #Seg 5
dralim(586, 701, perlin) #Seg 6
我可以显示我已经走了多远(不远):
ggplot(a, aes(x=num,y=s, colour=ss)) +geom_line() +stat_smooth(method="lm", formula="y~poly(x,2)")
要清楚。我正在将我的数据绘制在参考线上(上图)。底部图像显示了我的数据以及我在获取参考线方面的糟糕尝试(显然没有奏效)。