AlgebraOfGraphics.jl icon indicating copy to clipboard operation
AlgebraOfGraphics.jl copied to clipboard

facets: make linked axes dependent upon the direction keyword

Open rapus95 opened this issue 3 years ago • 6 comments

visual(BarPlot, direction=:x) links the x-axes as usual, which is wrong in this case.

rapus95 avatar Feb 01 '22 14:02 rapus95

As I just saw, it looks like AoG cannot handle the direction keyword at all since the axes are named as if the axes weren't flipped

rapus95 avatar Feb 02 '22 16:02 rapus95

Yes, it's waiting for https://github.com/JuliaPlots/Makie.jl/issues/926 to handle it without too many contorsions, but it's good to keep in mind that axes linking should also take this into account.

piever avatar Feb 02 '22 16:02 piever

until then, is there any easy way to flip the plot direction aside of manually drawing it with Makie directly?

rapus95 avatar Feb 08 '22 10:02 rapus95

You can probably hack your way around it with something like

@recipe(FlippedBarPlot) do scene
    return default_theme(scene, BarPlot)
end

Makie.convert_arguments(::Type{<:FlippedBarPlot}, x, y) = PlotSpec{BarPlot}(y, x, direction=:x)

plt = data((x=rand(3), y=["a", "b","c"])) * mapping(:x, :y) * visual(FlippedBarPlot)

where the association variable -> axis is preserved in the recipe FlippedBarPlot, so everything should work

piever avatar Feb 08 '22 12:02 piever

You can probably hack your way around it with something like

I also just encountered this issue and tried out the hack, but it seems it doesn't actualy use the x values but instead just integers 1:length(y). I'm not that familiar with the Makie recipe system, is that just due to a typo or something more involved?

jfb-h avatar Mar 02 '22 13:03 jfb-h

Ah just saw the other issue, sorry for the noise. Feel free to ignore!

jfb-h avatar Mar 02 '22 13:03 jfb-h