Skip to content

Instantly share code, notes, and snippets.

@mschauer
Last active October 29, 2018 11:49
Show Gist options
  • Select an option

  • Save mschauer/0b960ef32475e9211f4139c1b9c8c1c0 to your computer and use it in GitHub Desktop.

Select an option

Save mschauer/0b960ef32475e9211f4139c1b9c8c1c0 to your computer and use it in GitHub Desktop.
Makie confidence bands recipe
using Makie
import AbstractPlotting: plot!
@recipe(Band, x, ylower, yupper) do scene
Theme(;
default_theme(scene, Mesh)...,
color = RGBAf0(1.0,0,0,0.2)
)
end
function band_connect(n)
ns = 1:n-1
ns2 = n+1:2n-1
[ns ns .+ 1 ns2;
ns .+ 1 ns2 .+ 1 ns2 ]
end
function plot!(plot::Band)
coordinates = lift( (x, ylower, yupper) -> [x ylower; x yupper], plot[1], plot[2], plot[3])
connectivity = lift(x -> band_connect(length(x)), plot[1])
mesh!(plot, coordinates, connectivity;
color = plot[:color], colormap = plot[:colormap], colorrange = plot[:colorrange],
shading = false, visible = plot[:visible])
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment