Plots.jl color specific bars on plot

Viewed 103
n = 20
hgt = rand(n) .+ 1
bot = randn(n)
openpct = rand(n)
closepct = rand(n)
y = OHLC[(openpct[i] * hgt[i] + bot[i], bot[i] + hgt[i], bot[i], closepct[i] * hgt[i] + bot[i]) for i = 1:n]
ohlc(y)

Checked through attributes, i see markers but is there a way to color specific bars at defined index positions? Say i color these 2x bars yellow at x axis index position 11 and 15 for output:

enter image description here

1 Answers

There's probably a better way to do this, but you can get

enter image description here

with

julia> ohlc(y)

julia> ohlc!(OHLC[i ∈ (11, 15) ? y[i] : OHLC(NaN,NaN,NaN,NaN) for i in eachindex(y)], c=:red)
Related