-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Confidence Interval Band #366
Comments
Unfortunately it is not covered in the docs yet. |
Can you add some fake data to make your example runnable? Then it will be easier to help. |
Yes sorry, I updated the code above which you should now be able to run fully. |
I am not sure of the difference between
|
@Nosferican, @kir0ul here's how you would do it with AoG: using AlgebraOfGraphics, CairoMakie
using DataFrames: DataFrame
using Chain: @chain
using DataFrameMacros: @transform
df = @chain begin
DataFrame(x = [0:5; 0:5], sample = [fill(1, 6); fill(2, 6)])
@transform(:y = :x + :sample)
@transform(:lb = √(:y), :ub = :y^2)
end
data(df) * visual(LinesFill) * mapping(
:x, :y,
lower = :lb, upper = :ub,
color = :sample => nonnumeric,
layout = :sample => nonnumeric
) |> draw (@Nosferican, thanks for providing a more minimal example.) |
It may make sense to allow for a method w/o having to specify the |
That would be |
Is there a tutorial on how to do this with multiple bands? Looking to get a fan chart, e.g. like this: |
I wanted to implement this at some point but I didn't finish. I've just put the code into a draft PR greimel/AoGExtensions.jl#16 so that you have a look. Here's an example that works already. [Data]raw_df = mapreduce(vcat, 1:500) do i
T = 100
drift = rand([-0.2, 0, 0.2])
x = 1:T
y = [randn()]
for t ∈ 1:T-1
push!(y, drift + y[end] + randn())
end
DataFrame(; x, y, i, drift)
end What I still need to add is customization of breakpoints (these are currently hardcoded) |
This is great! I actually managed to get my own version almost working:
The reason I say "Almost" is because the red lines (not the band) are visible from behind the black line. I'd also like to add a legend saying which interval is which. I can't get |
Ahh, I figured it out!
|
Actually, do you know how I'd add a legend to this that tells users what each band means? (e.g. light yellow=68%, dark yellow = 95%, very dark = 99%) |
Also, would a continuous fan chart like this one be possible? |
Opened a new issue for fan charts here. |
The goal is to make this syntax work (note the visual(Band) * mapping(:year, :low, :high, alpha = :quantile) At some point I was working a PR to achieve that, but I didn't finish it. I hope to be able to get back to this at some point. |
Problem description
I would like to be able to plot a line with a confidence interval band, something like the plot below (which I believe is not possible at the moment using only
AlgebraOfGraphics.jl
alone).Proposed solution
I guess the implementation could use the
band()
function from Makie, and borrow some ideas for the API from VegaLite.jl or ggplot2.The text was updated successfully, but these errors were encountered: