GLMakie: Point2f not defined

Hi all,

I have run this code smoothly yesterday, but it can’t be run anymore, it triggers an error
UndefVarError: Point2f not defined

Stacktrace:
** [1] (::var"#1#3"{StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}})(a::Float64, b::Float64)**
** @ Main ./In[1]:12**
** [2] lift(f::Function, o1::Observable{Any}, rest::Observable{Any}; kw::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})**
** @ Makie ~/.julia/packages/Makie/NL7Xw/src/interaction/nodes.jl:13**
** [3] lift(f::Function, o1::Observable{Any}, rest::Observable{Any})**
** @ Makie ~/.julia/packages/Makie/NL7Xw/src/interaction/nodes.jl:10**
** [4] quadraticsliders(x::StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64})**
** @ Main ./In[1]:11**
** [5] quadraticsliders()**
** @ Main ./In[1]:4**
** [6] top-level scope**
** @ In[1]:24**
** [7] eval**
** @ ./boot.jl:373 [inlined]**
** [8] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)**
** @ Base ./loading.jl:1196**

I wonder how to make it works

  1. I have tried add using Meshes, not working
using GLMakie

function quadraticsliders(x=-5:0.01:5)
  fig = Figure()

  ax = Axis(fig[1, 1], xlabel="X", ylabel="Y")

  sl_a = Slider(fig[2, 1], range = -3:0.01:3, startvalue = 0.)
  sl_b = Slider(fig[1, 2], range = -3:0.01:3, horizontal = false, startvalue = 0.)

  points = lift(sl_a.value, sl_b.value) do a, b
      Point2f.(x, a.*x.^2 .+ b.*x)
  end

  l = lines!(points, color = :blue)

  onany((a,b)->axislegend(ax, [l], ["$(a)x² + $(b)x"]), sl_a.value, sl_b.value)

  limits!(ax, minimum(x), maximum(x), -10, 10)

  fig
end

quadraticsliders()

Try to downgrade GLMakie to version 0.4.7 …

I am on GLMakie 0.4.5 and can’t upgrade it to 0.4.7

You have too much stuff in your environment and some of it is holding the version of Makie back. You’re on quite the old version if it doesn’t have Point2f. Either try removing incompatible packages or start with a new environment for Makie related things.

1 Like

It looks like AbstractPlotting is pinning down GeometryBasics:

pkg> activate --temp
(jl_XveiI1) pkg> add AbstractPlotting
...
   Installed AbstractPlotting ─ v0.18.3
(jl_XveiI1) pkg> status -m GeometryBasics
      Status `/tmp/jl_XveiI1/Manifest.toml`
  [5c1252a2] GeometryBasics v0.3.12

0.3.12 is about one year older than the latest version which is 0.4.2.

As stated in its README, AbtractPlotting should no longer be used directly.
So as jules said, it is advisable to start from a fresh environment and only add the packages you need.

2 Likes

And if you should really need some old package versions you must add them to the compat section of your project.

I always create a backup of Manifest.toml when I have a working project before adding new packages,

1 Like

I just know about this stuff. This is why some things can’t be run anymore

Thanks a lot @ederag , I just know that the GeometryBasics version that is one year older is from AbstractPlotting.

@ufechner7 I want to know is it better to create new environment everytime we want to test Julia’ codes/file?

1 Like

For every new project I create a new environment:

mkdir new_project
cd new_project
julia --project="."
]add xxx

You don’t have to, but it makes it possible to use different versions of the same package per project. I often want to use old versions for old projects and new versions for new projects.

After the project has been created you can start julia like this:

julia --project

to activate it automatically. Of course any project can contain any number of scripts as long as these scripts need the same packages.

2 Likes

This one works,

I try

pkg> activate --temp
pkg> add <packagename>
julia> include<"glmakie2.jl">

to start a new environment and it still can’t work with the GLMakie, not opening the Makie GUI.
Capture d’écran_2022-07-16_16-30-14

using yours:

works amazingly. Thanks for the knowledge and help. Wish you all the best.