Skip to content

Conversation

@ajinkya-k
Copy link
Contributor

split off from #80

Copy link
Member

@palday palday left a 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,));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why disable the legend?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disabled it because the exact subject ID's dont matter and the legend was way too big to fit the plot. This is the current version deployed on embraceuncertainty.com:
image

Comment on lines 358 to 379
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Copy link
Contributor Author

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

Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

figgrid = draw(...)
fig = figgrid.figure

Copy link
Contributor Author

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

@ajinkya-k
Copy link
Contributor Author

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.

this is in reference to Figure 3.2 right?

@ajinkya-k
Copy link
Contributor Author

I think i can recreate banking to 45-degrees. Do we want to do median banking or average banking?

@palday
Copy link
Member

palday commented May 11, 2025

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!

@ajinkya-k
Copy link
Contributor Author

ajinkya-k commented May 11, 2025

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)

@palday
Copy link
Member

palday commented May 12, 2025

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.

@ajinkya-k
Copy link
Contributor Author

ajinkya-k commented May 12, 2025

@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

@ajinkya-k
Copy link
Contributor Author

@palday

For multiple.qmd figure we have two options (my preference is option A):

Option A:
image

Option B: this incorporates your suggestion but i resized the figure to 600 x 600
image

@ajinkya-k
Copy link
Contributor Author

Once we decide on the orientation for the cask-strength I think this is good to merge

@palday
Copy link
Member

palday commented May 13, 2025

@palday

For multiple.qmd figure we have two options (my preference is option A):

Option A: image

Option B: this incorporates your suggestion but i resized the figure to 600 x 600 image

Vertical matches the plot for crossed random effects, so let's do that.

Can you label the axis "cask within batch" though to make it very clear that we're looking at nested effects?

@ajinkya-k
Copy link
Contributor Author

ajinkya-k commented May 13, 2025

Will do. Just to clarify by vertical you mean option A right?

@palday
Copy link
Member

palday commented May 13, 2025

Will do. Just to clarify by vertical you mean option A right?

Yep, your preferred orientation 😄

Done!

@palday palday merged commit 8fe4d77 into JuliaMixedModels:main May 13, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants