logo

어웨이

어웨이

줄리아에서의 비동기 프로그래밍 @async

istaskstarted(task0) istaskdone(task0)


줄리아 좌표축 틱에 다른 내용 쓰는 방법 xticks = (1:10, 'a':'j')

using Plots

plot(randn(10), xticks = (1:10, 'a':'j'))
plot(randn(10), xticks = (2:2:10, 'A':'E'))

줄리아 레이텍 문자열에서의 보간법

https://github.com/JuliaStrings/LaTeXStrings.jl

https://discourse.julialang.org/t/plots-string-interpolation-in-labels/10799/4

using Plots, LaTeXStrings

t = 0:.01:2π
plt_ = []
for k = 1:4
    push!(plt_, plot(t, sin.(k*t), title = L"\sin(%$k t)",
          xticks = ([0, π, 2π], ["0", "π", "2π"])))
end
plot(plt_..., legend = :none)

줄리아 배열에서 원소 빈도수 세는 법

function frequency(arr)
    freq = Dict{eltype(arr), Int64}()
    for item in arr
        freq[item] = get(freq, item, 0) + 1
    end
    return freq
end

줄리아에서 시스템 이미지로 패키지 로드 속도 빠르게 하는 법

julia -J sysimage.so

using PackageCompiler
create_sysimage(["Plots"], sysimage_path="sys_plots.so", precompile_execution_file="precompile_plots.jl")
"julia.environmentPath": "C:\\Users\\대식\\path\\to\\your\\project",
"julia.additionalArgs": [
    "--sysimage",
    "C:\\Users\\대식\\path\\to\\sys_plots.so"
]

이거 글 좀 크다… 쉽게 끝날 일이 아님


줄리아 패키지 설치 속도 확인하는 법

https://discourse.julialang.org/t/any-way-to-speed-up-loading-large-precompiled-packages/98762/11

@time_import


줄리아 막대그래프에서 테두리 없애는 법 lw = 0


줄리아에서 데이터 읽어들일 때 깨지는 인코딩 문제 해결

https://github.com/JuliaStrings/StringEncodings.jl


줄리아 GR 백엔드 폰트 목록

https://gr-framework.org/fonts.html


다항함수 인터폴레이션의 실제 구현(수치해석)

using Plots, Polynomials

function interpolate(xs, ys)
    V = [x^(i-1) for x in xs, i in 1:length(xs)]
    coeffs = V \ ys
    return Polynomial(coeffs)
end
foo = sort(rand(5))
bar = randn(5)
p = interpolate(foo, bar)
plot(0:0.01:1, p.(0:0.01:1))
scatter!(foo, bar)

근데 이것보단 원래 있는 API로 하는 게 나을듯

https://juliamath.github.io/Polynomials.jl/stable/reference/#Polynomials.fit


줄리아 히트맵에서 특정 부붙 투명하게 남겨두는 법

# 색상은 1일 때만 빨간색, 나머지는 아무것도 렌더링되지 않도록
heatmap!(vf, x_, y_, nc_x',
    alpha = nc_x',
    color = [:transparent, :red],
    colorbar = :none,
    transpose = true
)