значение меток в контурном графике с использованием ggplot2 в R [дубликат]

Подходящим решением является KVO

. Прежде чем цикл добавит наблюдателя (предполагается, что queue является экземпляром OperationQueue)

queue.addObserver(self, forKeyPath:"operations", options:.new, context:nil)

Затем реализуем

override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
    if object as? OperationQueue == queue && keyPath == "operations" {
        if queue.operations.isEmpty {
            // Do something here when your queue has completed
            self.queue.removeObserver(self, forKeyPath:"operations")
        }
    } else {
        super.observeValue(forKeyPath: keyPath, of: object, change: change, context: context)
    }
}

Изменить:

В Swift 4 намного проще

Объявить свойство:

var observation : NSKeyValueObservation?

и создать наблюдателя

observation = queue.observe(\.operationCount, options: [.new]) { [unowned self] (queue, change) in
    if change.newValue! == 0 {
        // Do something here when your queue has completed
        self.observation = nil
    }
}
17
задан MYaseen208 29 November 2012 в 16:16
поделиться

1 ответ

с использованием пакета directlabels и собирающего раствора из этого

# Basic plot
v <- ggplot(volcano3d, aes(x, y, z = z))
library(directlabels)
v2 <- v + stat_contour(aes(colour = ..level..))
direct.label(v2, method="bottom.pieces")

enter image description here [/g1]

24
ответ дан Arthur Yip 20 August 2018 в 18:23
поделиться
  • 1
    с ggplot & gt; 2.0.0 вам нужно будет добавить method="bottom.pieces" (или top.pieces) к вызову direct.label – jaimedash 19 May 2016 в 01:04
Другие вопросы по тегам:

Похожие вопросы: