-
Notifications
You must be signed in to change notification settings - Fork 6
Moving R plots to julia #92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…her AoG version to compat
palday
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for this! I had a few suggestions for efficiency and making the plots better match the important details of the original.
It's far from trivial to match the lattice aspect = "xy" behavior, which goes back to some advice from Bill Cleveland about making the 'standard' line 45 degrees. (Logic is: the human eye is very good at detecting deviations from 45 degrees, so we quickly see deviations from standard. ) It's easy to have a 1:1 aspect ratio and a y=x line for the trivial case, but for the data here, we would have to do something like have the 45 degree line match the mean slope across participants.
| ) * | ||
| (visual(Scatter) + visual(Lines)); | ||
| (visual(Scatter) + visual(Lines)), | ||
| scales(Color = (; legend = false,)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why disable the legend?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| draw( | ||
| data(pastes) * | ||
| mapping( | ||
| :cask, | ||
| :strength, | ||
| col = :batch => sorter(sort!(combine(groupby(pastes, :batch), :strength => mean => "strength" ), :strength).batch) | ||
| ) * visual(Scatter; marker = '∘', markersize = 15, color = :blue) + | ||
| data(combine(groupby(pastes, [:cask, :batch]), :strength => mean => "strength" )) * | ||
| mapping( | ||
| :cask, | ||
| :strength, | ||
| col = :batch => sorter(sort!(combine(groupby(pastes, :batch), :strength => mean => "strength" ), :strength).batch) | ||
| ) * visual(Lines; color = :blue); | ||
| axis = (; xticklabelsize = 10), | ||
| figure = (; size=(700, 350)) | ||
| ); | ||
| f = current_figure(); | ||
| colgap!(f.layout, 4) | ||
| f |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| draw( | |
| data(pastes) * | |
| mapping( | |
| :cask, | |
| :strength, | |
| col = :batch => sorter(sort!(combine(groupby(pastes, :batch), :strength => mean => "strength" ), :strength).batch) | |
| ) * visual(Scatter; marker = '∘', markersize = 15, color = :blue) + | |
| data(combine(groupby(pastes, [:cask, :batch]), :strength => mean => "strength" )) * | |
| mapping( | |
| :cask, | |
| :strength, | |
| col = :batch => sorter(sort!(combine(groupby(pastes, :batch), :strength => mean => "strength" ), :strength).batch) | |
| ) * visual(Lines; color = :blue); | |
| axis = (; xticklabelsize = 10), | |
| figure = (; size=(700, 350)) | |
| ); | |
| f = current_figure(); | |
| colgap!(f.layout, 4) | |
| f | |
| batch_sort = sort!(combine(groupby(pastes, :batch), | |
| :strength => mean => :strength), | |
| :strength; rev=true).batch | |
| paste_means = combine(groupby(pastes, [:cask, :batch]), | |
| :sample, | |
| :strength => mean => "strength" ) | |
| draw( | |
| data(pastes) * | |
| mapping( | |
| :strength, | |
| :cask => "Cask within batch", | |
| row = :batch => sorter(batch_sort) | |
| ) * visual(Scatter; marker = '∘', markersize = 15, color = :blue) + | |
| data(paste_means) * | |
| mapping( | |
| :strength, | |
| :cask => "Cask within batch", | |
| row = :batch => sorter(batch_sort) | |
| ) * visual(Lines; color = :blue); | |
| # axis = (; xticklabelsize = 10), | |
| facet = (; linkyaxes=:minimal), | |
| figure = (; size=(350, 800)) | |
| ); | |
| f = current_figure() | |
| rowgap!(f.layout, 4) | |
| f |
closer to the original and avoids computing some things twice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the call f = current_figure() is needed because draw actually refurns a FigureGrid not a figure. Also this was the suggested way of using row and colgap with aog figure by julius
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left current_figure in this one, but if you look at the other suggestion, you'll see that I grab the figure out of the FigureGrid. 😉 I'm fine with leaving it as current_figure() though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh idk if i incorrectly applied the suggestion on my local but i got errors with that. can you paste a one line here to extract the figure from figure grid?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
figgrid = draw(...)
fig = figgrid.figureThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the version with cask on the x-axis looks better. If we want to keep the original orientation we should atleast make the figiure flatter or more square
this is in reference to Figure 3.2 right? |
|
I think i can recreate banking to 45-degrees. Do we want to do median banking or average banking? |
average, please, that would be swell! |
|
okay! I have the median version ready so i will push because it has other computation in there, but once I have it working i will switch to average banking (EDIT: I implemented median because it has a closed form solution) |
@ajinkya-k oh in that case, median is fine. |
|
@palday I checked the lattice package documentation and they use median banking. So should we stick with that? see page 142: https://cran.r-project.org/web/packages/lattice/lattice.pdf |
Co-authored-by: Phillip Alday <[email protected]>
|
Once we decide on the orientation for the cask-strength I think this is good to merge |
|
Will do. Just to clarify by vertical you mean option A right? |
Done! |





split off from #80