Skip to content

Instantly share code, notes, and snippets.

@abikoushi
Created May 22, 2025 10:08
Show Gist options
  • Save abikoushi/224ec4fa866826af996c7670811f2920 to your computer and use it in GitHub Desktop.
Save abikoushi/224ec4fa866826af996c7670811f2920 to your computer and use it in GitHub Desktop.
My first try CairoMakie.jl
using Random
using Distributions
using CairoMakie
using FileIO
beta = [1, 2]
rng = Random.default_rng(1234)
X = [ones(10) randn(rng, 10)]
y = X * beta + randn(rng, 10)
betahat = X \ y
fig =Figure()
ax = Axis(fig[1, 1])
scatter!(ax, X[:,2] , y)
line1 = ablines!(ax, beta[1], beta[2])
line2 = ablines!(ax, betahat[1], betahat[2], color = :orange, linestyle=:dash)
Legend(fig[1, 2],
[line1, line2],
["true", "fitted"])
fig
save("abline.png", fig)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment