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

Misplaced yticks when mirroring inside ticks and linking yaxes

Open kimauth opened this issue 2 years ago • 3 comments

When using inside mirrored yticks, the right spines ticks seem not to be adjusted correctly upon changes to the yaxis.

set_theme!(Theme(
    Axis = (
        xticksmirrored = true,
        yticksmirrored = true,
        xtickalign = 1,
        ytickalign = 1,
    ),
))

f = Figure()
ax_t = Axis(f[1,1])
lines!(ax_t, rand(10))
ax_n = Axis(f[1,2])
lines!(ax_n, rand(10))

# linkyaxes!(ax_n, ax_t)
colgap!(f.layout, 12.)
linkyaxes!(ax_n, ax_t)

misplaced_ticks1

When swapping the linkyaxes! and colgap! commands, the ticks end up in a different position, but still not really correct: misplaced_ticks2

This is on Makie v0.17.13.

kimauth avatar Aug 10 '22 16:08 kimauth

Here is another example of this, without linking axes this time. It's an example from the docs, I only added the yticksmirrored option.

using CairoMakie
using DelimitedFiles

volcano = readdlm(Makie.assetpath("volcano.csv"), ',', Float64)

f = Figure()
Axis(f[1, 1]; yticksmirrored=true)

co = contourf!(volcano, levels = 10)

Colorbar(f[1, 2], co)

f

misplaced_ticks_contourf

kimauth avatar Aug 15 '22 11:08 kimauth

Yes good catch, there were some edits to observable updates with ticks a while ago, those must have broken whatever the mirroring uses. Or the mirroring itself was buggy from the start and just not visible in my specific tests.

jkrumbiegel avatar Aug 15 '22 11:08 jkrumbiegel

I have the same problem, except in addition to being misaligned, my mirrored inner-ticks also end up on the outside. This is without linking any axes.

	X = rand(100) .+ 100
	
	f = Figure()
	axisargs = (
			xticksmirrored=true,
			yticksmirrored=true,
			xtickalign=1,
			ytickalign=1, 
	)
	
	scatter(f[1,1], X, axis=(;axisargs...,))
	scatter(f[1,2], X .* 10, axis=(;axisargs...,),)
	scatter(f[2,1], X, axis=(;axisargs...,))
	scatter(f[2,2], X .* 10, axis=(;axisargs...,),)

yticks-bug-linear

Weirdly enough, this only seems to affect the plot at GridPosition[1,1] if it is created first. If I switch the order of construction, Makie seems to fix itself.

	X = rand(100) .+ 100
	
	f = Figure()
	axisargs = (
			xticksmirrored=true,
			yticksmirrored=true,
			xtickalign=1,
			ytickalign=1, 
	)
	
	scatter(f[1,2], X .* 10, axis=(;axisargs...,))
	scatter(f[1,1], X, axis=(;axisargs...,),)
	scatter(f[2,1], X, axis=(;axisargs...,))
	scatter(f[2,2], X .* 10, axis=(;axisargs...,),)

yticks-bug-linear-fix

Btw, would it be possible to rename xticksmirrored to xtickmirrored (i.e. singular instead of plural). xticksmirrored and xminorticksmirrored are the only attributes that are plural: compare this to xtickalign, xtickcolor xtickformat etc. The only exception seems to be xticks, which you could justify because of common usage and the fact that it expects a range of values.

I am using Julia Version 1.8.0-rc3 on an M1 Mac and GLMakie v0.6.13

adityanprasad avatar Aug 17 '22 01:08 adityanprasad

Soooo, I stumbled over that issue today as I had a similar problem with mirroring ticks... until I found out I was using an old version of Makie (v0.20.3). Everything works fine (including all examples here) under the latest version (v0.20.7), so some recent change fixed it 🥳

egavazzi avatar Feb 21 '24 19:02 egavazzi

was fixed in https://github.com/MakieOrg/Makie.jl/pull/3581

jkrumbiegel avatar Feb 22 '24 07:02 jkrumbiegel