I’m interested in understanding how one can rotate a whole axis/plot in Makie, in order to produce visualizations like the one below.
This solution was posted by Simon Danisch on Slack:
using GLMakie
f, ax, pl = barplot(rand(5), bar_labels=:y, figure=(resolution=(500, 500),))
hideydecorations!(ax)
hidespines!(ax, :t, :r, :l)
hidexdecorations!(ax, ticks=false)
tightlimits!(ax)
f
img = Makie.colorbuffer(ax.scene)
f, ax, pl = scatter(rand(Point2f, 100), axis=(aspect = DataAspect(),))
impl = image!(ax, 0..1, 0..1, rotr90(img))
display(f)
rotate!(impl, -0.25pi)
translate!(impl, 0.5, 1.2, 0)
xlims!(ax, 0, 2)
ylims!(ax, 0, 2)
Although it’s a great solution, I’v got some problems with it. First of all, it does not seem to work with CairoMakie
. Secondly, I’d like for the visualization to be fully svg
, which I’m guessing would not be the case here, since img = Makie.colorbuffer(ax.scene)
would rasterize the original scene.
Following the Julia Data Science book by @lazarusA , I tried the following:
function add_box_inset(fig; left=100, right=250, bottom=200, top=300,
bgcolor=:grey90)
inset_box = Axis(fig, bbox=BBox(left, right, bottom, top),
xticklabelsize=12, yticklabelsize=12, backgroundcolor=bgcolor)
# bring content upfront
translate!(inset_box.scene, 0, 0, 10)
qx = qrotation(Vec(1, 0, 0), pi / 4)
rotate!(inset_box.scene,qr)
elements = keys(inset_box.elements)
filtered = filter(ele -> ele != :xaxis && ele != :yaxis, elements)
foreach(ele -> translate!(inset_box.elements[ele], 0, 0, 9), filtered)
return inset_box
end
But with no success. Any ideas?