【问题标题】:Plot progress bar in image在图像中绘制进度条
【发布时间】:2013-03-22 15:20:20
【问题描述】:

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

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

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

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

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

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

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

等等

有什么想法吗?

【问题讨论】:

  • 您在寻找热图吗?
  • 我编辑了问题

标签: r progress-bar


【解决方案1】:

以下是几种类型的进度条。这是你要找的吗?

#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()

【讨论】:

  • 我对此表示怀疑。 OP 说他们想在绘图中添加图形元素。他们对“进度条”一词的使用可能有点误导。
  • @joran 你是对的。我想在每个图中都有一些“进度条”。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-04-13
  • 2011-10-26
  • 1970-01-01
  • 2020-08-15
  • 2016-03-26
相关资源
最近更新 更多