Skip to content

Instantly share code, notes, and snippets.

@jkrumbiegel
Created June 17, 2024 06:45
Show Gist options
  • Save jkrumbiegel/cf665e02b3e1c87605f7cf9a4799695e to your computer and use it in GitHub Desktop.
Save jkrumbiegel/cf665e02b3e1c87605f7cf9a4799695e to your computer and use it in GitHub Desktop.
@recipe(AxisFunction) do scene
default_theme(scene, Lines)
end
Makie.data_limits(::AxisFunction) = Rect3f(Point3f(NaN), Vec3f(NaN))
Makie.boundingbox(::AxisFunction, space::Symbol = :data) = Rect3f(Point3f(NaN), Vec3f(NaN))
function Makie.plot!(p::AxisFunction)
func = p[1]
# # could use transf to compute points equidistant in transformed space
# scene = Makie.parent_scene(p)
# transf = Makie.transform_func(scene)
limits = Makie.projview_to_2d_limits(p)
points = lift(p, func, limits) do func, limits
xs = range(first.(extrema(limits))..., length = 400)
Makie.Point2d.(xs, func.(xs))
end
lines!(p, p.attributes, points)
return p
end
scatter(cumsum(randn(100)))
axisfunction!(sin)
current_figure()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment