I wondered whether the following is possible in Makie.
import numpy as np
import matplotlib.pyplot as plt
a = 
for item in x:
x = np.arange(-10., 10., 0.2)
sig = sigmoid(x)
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
# Move left y-axis and bottom x-axis to centre, passing through (0,0)
# Eliminate upper and right axes
# Show ticks in the left and lower axes only
I have looked through the documentation but not found something to change the position of the spines such that they are centered through (0,0).
Thanks for any help!
Not inbuilt, although one could probably hack it in several ways. You could look at
ax.xaxis, I think it has an
endpoints observable. You could try setting that to the vertical middle of the axis area you have in ax.scene.px_area
When I was using Plots.jl, I would always make my axis go through (0, 0). Nowaday, I am using Makie and not really missing that feature. But for some plots it is really nice to have the option. Are there plans to add built-in support for this?
Not really plans, but it would in principle not be that difficult to add I think. It might just get a bit more messy with the observables if there are more possible states than top and bottom for xaxisposition etc.
In a quick try I already saw that the grid lines break when there’s an additional
:center state, so stuff like that would need to be cleaned up.
Thanks for the idea @jules, I gave it a try here’s what came out. I managed to make the axis go through the middle, however the grid is know messed up.
fig = Figure()
xticks = -5:1:5
yticks = -5:1:5
ax = Axis(fig[1, 1], aspect=AxisAspect(1), xticks=xticks, yticks=yticks)
limits!(ax, -5.5, 5.5, -5.5, 5.5)
hidespines!(ax, :t, :r)
xend = ax.xaxis.attributes.endpoints
yend = ax.yaxis.attributes.endpoints
x1, x2 = xend
y1, y2= yend
Δy = (y2 - y1)/2
Δx = (x2 - x1)/2
xend = ([x1, x1 + Δy], [x2, x2 + Δy])
yend = ([y1 + Δx, y1], [y2 + Δx, y2])
xs = -5:0.1:5
lines!(ax, xs, 5*sin.(xs))
Ah sorry, did not see your last post. But yes I had the same problem