Skip to content

show how to modify a AoG plot using Makie#268

Closed
tbenst wants to merge 1 commit intoMakieOrg:masterfrom
tbenst:patch-1
Closed

show how to modify a AoG plot using Makie#268
tbenst wants to merge 1 commit intoMakieOrg:masterfrom
tbenst:patch-1

Conversation

@tbenst
Copy link
Copy Markdown

@tbenst tbenst commented Aug 20, 2021

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

Comment thread docs/src/FAQs.md
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
Copy Markdown
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
Copy Markdown
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 thread docs/src/FAQs.md
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
Copy Markdown
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
Copy Markdown
Author

tbenst commented Sep 9, 2021

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

@tbenst
Copy link
Copy Markdown
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

@jkrumbiegel
Copy link
Copy Markdown
Member

there's now a tutorial that shows these aspects https://aog.makie.org/v0.10.0/tutorials/intro-vi

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.

4 participants