Skip to content
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

show how to modify a AoG plot using Makie #268

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tbenst
Copy link

@tbenst tbenst commented Aug 20, 2021

Thought it'd be useful to highlight that AoG plots are "just" Makie

fg = draw(hist2; figure = (resolution = (600, 400),)) #hide

lines(fg.figure[1, 1], 0..2pi, cos) #hide
fg.figure.content[1].xticklabelrotation = Float64(pi/6)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for the example! I was thinking that it would be better IMO if here one was modifying the figure directly rather than the axes (the axes should ideally be accessed as fg.grid[i, j].axis). Maybe one could change backgroundcolor for instance, or any other figure attribute?

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
fg.figure.content[1].xticklabelrotation = Float64(pi/6)
only(contents(fg.figure[1, 1])).xticklabelrotation = Float64(pi/6)

is what the current Makie API prescribes I think.

Comment on lines +128 to +134
using AlgebraOfGraphics, CairoMakie #hide

df = (x = exp.(rand(1000)),) #hide
hist2 = data(df) * mapping(:x => log => "log(x)") * histogram() #hide
fg = draw(hist2; figure = (resolution = (600, 400),)) #hide

lines(fg.figure[1, 1], 0..2pi, cos) #hide
Copy link
Collaborator

Choose a reason for hiding this comment

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

To build on top of the previous example, you should be able to just do @example combined-2, without having to copy and hide what comes before.

@tbenst
Copy link
Author

tbenst commented Sep 9, 2021

apologies--I will get to this, crunching for a paper deadline...

@tbenst
Copy link
Author

tbenst commented Sep 15, 2021

adding a note-to-self to also contribute something on how to change ordering since took me a while to figure out

using PalmerPenguins, DataFrames
penguins = dropmissing(DataFrame(PalmerPenguins.load()))
penguins.island = CategoricalArray(penguins.island, ordered=true)
levels!(penguins.island, ["Dream", "Biscoe", "Torgersen"])
first(penguins, 6)
penguin_frequency = aog.data(penguins) * frequency() * mapping(:species)
plt = penguin_frequency * mapping(color = :island, dodge = :island)
draw(plt)

image

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.

3 participants