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

Tweaking a plot #44

Closed
greimel opened this issue May 6, 2020 · 4 comments
Closed

Tweaking a plot #44

greimel opened this issue May 6, 2020 · 4 comments

Comments

@greimel
Copy link
Collaborator

greimel commented May 6, 2020

I am posting examples of how to tweak a plot for future reference. When I find time I will set up a docs PR including what I posted in #40 and #42 (unless a more convenient way to achieve theses things is implemented).

Simple baseline plot

using AbstractPlotting, CairoMakie, MakieLayout, AlgebraOfGraphics

N = 500
x = rand(N)
df = DataFrame(x = x, y = x .+ randn(N))

cols = style(:x, :y)
scat = spec(Scatter)
pipeline = cols * scat
aog_simple = data(df) * pipeline

aog_simple |> draw

scene, layout = MakieLayout.layoutscene()

AlgebraOfGraphics.layoutplot!(scene, layout, aog_simple)

simple-aog

Adjusting color and transparency

grd_lay = layout.content[1].content # get the `GridLayout`
lax = grd_lay.content[1].content # get the `LAxis`
lax.scene.plots[1].color[] = (:red, 0.5)

simple-aog-color-alpha

@asinghvi17
Copy link
Member

asinghvi17 commented May 6, 2020

It might be useful to explicitly show how you get the LAxis in docs - from there, any manipulation becomes easy to do.

@greimel
Copy link
Collaborator Author

greimel commented May 6, 2020

I edited the code to make to make this more explicit.

I also just found out that one can do spec(Scatter, alpha=0.2), which is nice.

@jkrumbiegel
Copy link
Member

also for future reference, instead of

grd_lay = layout.content[1].content # get the `GridLayout`
lax = grd_lay.content[1].content # get the `LAxis`

you can now do

grd_lay = contents(layout)[1]
lax = contents(grd_lay)[1]

@piever
Copy link
Collaborator

piever commented May 9, 2021

Closed by #155

@piever piever closed this as completed May 9, 2021
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

No branches or pull requests

4 participants