JuliaPsychometrics / ItemResponsePlots.jl

Visualizations for item response models with Makie.jl
https://juliapsychometrics.github.io/ItemResponsePlots.jl/
MIT License
3 stars 0 forks source link

Hatched confidence intervals #28

Open p-gw opened 3 months ago

p-gw commented 3 months ago

Try how patterned confidence intervals look based on Makie.LinePattern:

col = "#f43f5e"

pat = Makie.LinePattern(;
    direction = Vec2f(1, -1),
    width = 0.5,
    tilesize = (4, 4),
    linecolor = col,
    background_color = :transparent,
)

x = range(-3, 3, 200)

lower = Point2f.(x, irf.(OnePL, x, Ref((; b = -0.25)), 1))
mid = Point2f.(x, irf.(OnePL, x, Ref((; b = 0.0)), 1))
upper = Point2f.(x, irf.(OnePL, x, Ref((; b = 0.25)), 1))

polygon = [lower..., upper[end:-1:1]..., lower[1]]

fig = Figure()
ax = Axis(fig[1, 1])

hlines!(ax, [0, 1], color = "#d4d4d4")
poly!(ax, polygon, color = pat)
lines!(ax, mid, color = col, linewidth = 1)
xlims!(ax, -3, 3)

fig

fig