MakieOrg / Makie.jl

Interactive data visualizations and plotting in Julia
https://docs.makie.org/stable
MIT License
2.4k stars 310 forks source link

Allow passing a seed or RNG for use in jittering raincloud plots #2455

Open ericphanson opened 1 year ago

ericphanson commented 1 year ago

So downstream projects can have reproducible CI plots without resorting to Random.seed!.

SimonDanisch commented 1 year ago

You can set that Ref: https://github.com/MakieOrg/Makie.jl/blob/master/src/basic_recipes/raincloud.jl#L12

jkrumbiegel commented 1 year ago

Wouldn't it still be better to have a seed argument that we could use for all plots having random components? Even though the code says

# A bit of a lazy solution, but it doesn't seem to be desirably to
# pass the RNG through the plotting command

I don't agree with that assessment.

SimonDanisch commented 1 year ago

Yeah, I'm happy to have it changed to be a plot attribute!

ericphanson commented 1 year ago

Ah, thanks for pointing to that Ref. If it uses that then Random.seed! wouldn’t work (edit: nvm, saw it just points to the global one, so Random.seed!(123) should be OK).

Agreed with @jkrumbiegel that allowing local config is preferable to global! Also would be nice to get to pass a RNG not just a seed, so we could eg use StableRNGs if desired.

jkrumbiegel commented 1 year ago

We could make it dispatch depending on whether it's an RNG or an Int? Then the keyword shouldn't be seed but rng I guess (even though an Int would be a seed, but it seems cumbersome for simple cases to pass a whole generator).

ericphanson commented 1 year ago

Hm, my thinking is this wouldn't be a super common use-case (e.g. most interactive use would be without specifying a seed/rng), so when you do need it it's probably fine to ask the user create the RNG

ericphanson commented 1 year ago

btw, I got a notification about a failed CI workflow triggered by this issue: https://github.com/MakieOrg/Makie.jl/actions/runs/3565502034. Strange!