Created
May 22, 2025 10:08
-
-
Save abikoushi/224ec4fa866826af996c7670811f2920 to your computer and use it in GitHub Desktop.
My first try CairoMakie.jl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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