2013-03-22 41 views
-1

我使用R在一天中的每个小时绘制24个关于温度的不同图像。在图像中绘制进度条

而不是每个图(即00:00; 01:00,02:00等)添加一个标签,我想有一个“进度栏”在每个图的顶部移动一步之后每个情节。

例如,在每个图的顶部;我想有这样的事情:

情节-次数1.pdf:-------一-----------

情节-2.pdf:--- ------一个---------

积通3.PDF:----------- A -------

情节-3.pdf:------------- A -----

任何想法?

+0

您是否在寻找热图? – 2013-03-22 15:24:40

+0

我编辑了问题 – Ben 2013-03-23 11:52:57

回答

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() 
+0

我对此表示怀疑。 OP表示他们想要将图形元素添加到图中。他们对“进度条”一词的使用可能有点误导。 – joran 2013-03-22 16:14:25

+0

@joran你说得对。我想在每个图中都有一些“进度条”。 – Ben 2013-03-23 11:53:23