2013-03-22 69 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