Closed yibeichan closed 4 years ago
Thanks Yibei!
@Yibeichan Why did you add the dot in your first update (pos[1, :] = zeros(noofwalks)
)?
Oh sorry, I made a typo in my notebook and wrote it as zero(noofwalks)
which equals 0 so I need to use .=
, but you’re right, it should be ‘= zeros(noofwalks)'
On Sun, Sep 27, 2020 at 7:24 AM, Rob J Goedman notifications@github.com wrote:
@Yibeichan [https://github.com/Yibeichan] Why did you add the dot in your first update ( pos[1, :] = zeros(noofwalks) )?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub [https://github.com/StatisticalRethinkingJulia/StatisticalRethinking.jl/pull/100#issuecomment-699642026] , or unsubscribe [https://github.com/notifications/unsubscribe-auth/AE3VE4B5LE5T3EEH2B3GLXLSH5DJ3ANCNFSM4R3KKSAQ] .
@Yibeichan What do you think of doing it this way?
p1 = plot(csum, leg=false)
title!("No of random walks = $(noofwalks)", color=:black)
plot!(p1, csum[:, Int(floor(noofwalks/2))], leg=false)
xtick_pos = [5,9,17]
xtick_labels = ("step 4", "step 8", "step 16")
p1 = plot(csum, leg=false, xticks=(xtick_pos,xtick_labels))
title!("No of random walks = $(noofwalks)", color=:black)
plot!(p1, csum[:, Int(floor(noofwalks/2))], leg=false, color=:black)
for (i,pos) in enumerate(xtick_pos)
plot!(p1, [pos], seriestype="vline")
end
savefig("$ProjDir/Fig-01-06.1.png")
This one works well, but I prefer the original one, which is more straightforward. Also, I’m using Pluto.jl and will get “multiple definitions” error if using for (i,pos) in enumerate(xtick_pos) because pos has been defined for the grid at the beginning. I think it works fine in jupyter notebook. But just in case someone is also using Pluto, it will be better to name differently :) On Sun, Sep 27, 2020 at 10:32 AM, Rob J Goedman notifications@github.com wrote:
@Yibeichan [https://github.com/Yibeichan] What do you think of doing it this way?
p1 = plot(csum, leg=false) title!("No of random walks = $(noofwalks)", color=:black) plot!(p1, csum[:, Int(floor(noofwalks/2))], leg=false) xtick_pos = [5,9,17] xtick_labels = ("step 4", "step 8", "step 16") p1 = plot(csum, leg=false, xticks=(xtick_pos,xtick_labels)) title!("No of random walks = $(noofwalks)", color=:black) plot!(p1, csum[:, Int(floor(noofwalks/2))], leg=false, color=:black) for (i,pos) in enumerate(xtick_pos) plot!(p1, [pos], seriestype="vline") end
savefig("$ProjDir/Fig-01-06.1.png")
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub [https://github.com/StatisticalRethinkingJulia/StatisticalRethinking.jl/pull/100#issuecomment-699664095] , or unsubscribe [https://github.com/notifications/unsubscribe-auth/AE3VE4CN5DDQZYECVDLVOUDSH5ZL7ANCNFSM4R3KKSAQ] .
The 2nd pos
is only visible in the for
loop. But your point is valid! I'll change it to indx
.
Aha, thank you!
On Sun, Sep 27, 2020 at 12:02 PM, Rob J Goedman notifications@github.com wrote:
The 2nd pos is only visible in the for loop. But your point is valid! I'll change it to indx .
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub [https://github.com/StatisticalRethinkingJulia/StatisticalRethinking.jl/pull/100#issuecomment-699674581] , or unsubscribe [https://github.com/notifications/unsubscribe-auth/AE3VE4H7M5IZ7IVD7TF5GV3SH6D57ANCNFSM4R3KKSAQ] .
correct the index in
snippet 4.1 plot