绘制图像中的进度条

时间:2013-03-22 15:20:21

标签: r progress-bar

我正在使用R来绘制关于当天每小时温度的24张不同图像。

不是在每个地块上添加标签(即00:00; 01:00,02:00等),我希望在每个地块的顶部都有一个“进度条”,每个地块后面移动一步曲线图。

例如,在每个图的顶部;我想要这样的东西:

Plot-1.pdf:------- A -----------

Plot-2.pdf:--------- A ---------

Plot-3.pdf:----------- A -------

Plot-3.pdf:------------- A -----

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

以下是几种类型的进度条。这是你在找什么?

#First Type ===============================

total <- 20
# create progress bar
pb <- txtProgressBar(min = 0, max = total, style = 3)
for(i in 1:total){
   Sys.sleep(0.1)
   # update progress bar
   setTxtProgressBar(pb, i)
}
close(pb)

#Second Type ==============================

total <- 20
# create progress bar
pb <- tkProgressBar(title = "progress bar", min = 0,
                max = total, width = 300)

for(i in 1:total){
   Sys.sleep(0.1)
   setTkProgressBar(pb, i, label=paste( round(i/total*100, 0),
                                    "% done"))
}
close(pb)

#Third Type ==============================

# create progress bar
pb <- winProgressBar(title = "progress bar", min = 0,
                 max = total, width = 300)

for(i in 1:total){
   Sys.sleep(0.1)
   setWinProgressBar(pb, i, title=paste( round(i/total*100, 0),
                                    "% done"))
}
close(pb)

#Fourth Type ================================

foo <- function(...){
    total <- 40
    pb <- txtProgressBar(min = 0, max = total, style = 3)
    # computation block 1
    for(i in 1:20){
        Sys.sleep(0.1)
        setTxtProgressBar(pb, i)
    }

    # computation block 2
    for(i in 21:total){
        Sys.sleep(0.1)
        setTxtProgressBar(pb, i)
    }
    close(pb)
}

# Run it             
foo()