You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 29, 2021. It is now read-only.
I often want to group and facet plots. That's why I mostly call ggplot2 via RCall.jl so far. I played around a litte bit. I thought I share what I have so that other can start from here.
Basic faceting looks like this:
What I did is
Group the data (using DataFrames.jl)
Create panels for each group
Adjust the limits across all panels
remove the axis name everywhere except at the boundary
add titles for each panel
What's still to improve
I tried to remove the axis ticknames, but my function doesn't work.
Removing the axis names messed up the alignment of the panels
I would like to have only one x instead of a label in each scene.
The titles of the panels to too big and the gap between the plot and the title is too big. Ideally there could be a visual link like in ggplot2.
compare ggplot2 (copied from the manual)
Julia code for the plot at the top:
using Makie, StatsMakie, Random, DataFrames
N =100
x =randn(N)
y =randn(N)
g1 =rand(["color $i"for i in1:3], N)
g2 =rand(["marker $i"for i in1:3], N)
df =DataFrame(x=x, y=y, g1=g1, g2=g2)
# common_limitsfunctionmin_range(vec)
min, max =extrema(vec)
range = max - min
min, range
endfunctionbox(x, y)
x_min, x_range =min_range(x)
y_min, y_range =min_range(y)
FRect(x_min, y_min, x_range, y_range)
end# omit axis annotations and labels for all but leftfunctionomit_y_name!(axis)
old_names = axis[:names][:axisnames].val
axis[:names][:axisnames] = (old_names[1], "")
end## Doesn't workfunctionomit_y_tickslabels!(axis)
@show old_labels = axis[:ticks][:labels].val
axis[:ticks][:labels] = (old_labels[1], old_labels[2] .^0)
end
faceted_scene =map(enumerate(groupby(df, :g1))) do isubdf
i, subdf = isubdf
scn =scatter(Data(subdf), :x, :y, limits=box(df[:x], df[:y]))
i !=1&&omit_y_name!(scn[Axis])
title(scn, string(subdf[:g1][1]))
end|> vbox
I also played a bit with legends for grouped data here.
The text was updated successfully, but these errors were encountered:
Makie's support for layouting isn't the best at the moment, because everything lives in data coordinates. We're working on solutions to this - @jkrumbiegel kindly provided a layout constraint solver - and it is certainly planned to integrate that (hopefully, by moving the axis out of data space).
In its current state, it's unlikely that what you're proposing is possible in Makie. However, it's absolutely the intention that things like that be made possible in the future.
I often want to group and facet plots. That's why I mostly call
ggplot2
viaRCall.jl
so far. I played around a litte bit. I thought I share what I have so that other can start from here.Basic faceting looks like this:
What I did is
DataFrames.jl
)What's still to improve
x
instead of a label in each scene.ggplot2
.compare
ggplot2
(copied from the manual)Julia code for the plot at the top:
I also played a bit with legends for grouped data here.
The text was updated successfully, but these errors were encountered: