jokergoo / circlize

Circular visualization in R
http://jokergoo.github.io/circlize_book/book/
Other
959 stars 141 forks source link

How to add a error bar to circos.barplot? #361

Closed liujilei156231 closed 1 year ago

liujilei156231 commented 1 year ago

Hello, I want to add a error bar to circos.barplot.How can I finish it?

Thanks!

jokergoo commented 1 year ago

No easy way, you have to add it manually.

liujilei156231 commented 1 year ago

Yeah,the circos.connect module could achieve this goal, but it is too complex. So, expect circlize team to encapsulate this functionality. Thanks!

jokergoo commented 1 year ago

Error bars are basically segments. Let me give you an example:


circos.initialize(letters[1:4], xlim = c(0, 10))
circos.track(ylim = c(0, 1.2), panel.fun = function(x, y) {
    value = runif(10)
    mid = 1:10 - 0.5
    circos.barplot(value, mid, col = 1:10)

    error = value*0.2

    circos.segments(mid, value, mid, value + error)
    circos.segments(mid - 0.1, value + error, mid + 0.1, value + error)
})
circos.clear()
image
liujilei156231 commented 1 year ago

Thanks!It's a simple implementation.