MakieOrg / Makie.jl

Interactive data visualizations and plotting in Julia
https://docs.makie.org/stable
MIT License
2.41k stars 312 forks source link

Corrupted marker with Point2 instead of Point2f #2778

Closed ederag closed 5 months ago

ederag commented 1 year ago

Instead of three hexagons (as shown in https://github.com/MakieOrg/Makie.jl/issues/2777; a similar code is used here), the result of

using CairoMakie
a = 0.5 # hexagon radius
vertices = [
    Point2(  # workaround: change to Point2f
        a * cos(θ),
        a * sin(θ)
    )
    for θ in range(1/6 * pi, 13/6 * pi, length = 7)
]
hexagon = Makie.Polygon(vertices)
points = a .* Point2[(0, 0), (sqrt(3), 0), (sqrt(3)/2, 1.5)]
scatter(points,
    marker = hexagon,
    markersize = 1,
    markerspace = :data,
    color = 1:3,
    axis = (; aspect = 1, limits = a .* (-2, 4, -2, 4))
)

is weird: image

It might be related to #1419 or https://github.com/MakieOrg/Makie.jl/pull/2573, as it has to do with single vs double precision. The funny thing is that here lower precision gives better results, so it might be entirely different.

Note: This was with CairoMakie v0.10.2.

With GLMakie v0.8.2 there is an error:

Details

```julia Failed to show value: InexactError: trunc(Int64, NaN) trunc@float.jl:781[inlined] round@float.jl:359[inlined] ftvec@bezier.jl:475[inlined] _broadcast_getindex_evalf@broadcast.jl:670[inlined] _broadcast_getindex@broadcast.jl:643[inlined] getindex@broadcast.jl:597[inlined] macro expansion@broadcast.jl:961[inlined] macro expansion@simdloop.jl:77[inlined] copyto!@broadcast.jl:960[inlined] copyto!@broadcast.jl:913[inlined] copy@broadcast.jl:885[inlined] materialize@broadcast.jl:860[inlined] convert_command(::Makie.MoveTo)@bezier.jl:478 make_outline(::Makie.BezierPath)@bezier.jl:447 render_path(::Makie.BezierPath, ::Int64)@bezier.jl:507 render(::Makie.TextureAtlas, ::Makie.BezierPath)@texture_atlas.jl:393 (::Makie.var"#49#50"{Makie.TextureAtlas, Makie.BezierPath})()@texture_atlas.jl:301 get!(::Makie.var"#49#50"{Makie.TextureAtlas, Makie.BezierPath}, ::Dict{UInt32, Int64}, ::UInt32)@dict.jl:481 insert_glyph!@texture_atlas.jl:300[inlined] insert_glyph!(::Makie.TextureAtlas, ::Makie.BezierPath)@texture_atlas.jl:295 glyph_index!@texture_atlas.jl:277[inlined] glyph_uv_width!@texture_atlas.jl:285[inlined] primitive_uv_offset_width@texture_atlas.jl:450[inlined] #57@texture_atlas.jl:454[inlined] #map#13@Observables.jl:564[inlined] primitive_uv_offset_width@texture_atlas.jl:454[inlined] #187@drawing_primitives.jl:231[inlined] get!(::GLMakie.var"#187#194"{Observables.Observable{FreeTypeAbstraction.FTFont}, Makie.TextureAtlas, Observables.Observable{Makie.BezierPath}}, ::Dict{Symbol, Any}, ::Symbol)@dict.jl:481 (::GLMakie.var"#182#189"{GLMakie.Screen{GLFW.Window}, Makie.Scene, MakieCore.Scatter{Tuple{Vector{GeometryBasics.Point{2, Float32}}}}})(::Dict{Symbol, Any})@drawing_primitives.jl:230 (::GLMakie.var"#168#171"{GLMakie.var"#182#189"{GLMakie.Screen{GLFW.Window}, Makie.Scene, MakieCore.Scatter{Tuple{Vector{GeometryBasics.Point{2, Float32}}}}}, GLMakie.Screen{GLFW.Window}, Makie.Scene, MakieCore.Scatter{Tuple{Vector{GeometryBasics.Point{2, Float32}}}}})()@drawing_primitives.jl:111 get!(::GLMakie.var"#168#171"{GLMakie.var"#182#189"{GLMakie.Screen{GLFW.Window}, Makie.Scene, MakieCore.Scatter{Tuple{Vector{GeometryBasics.Point{2, Float32}}}}}, GLMakie.Screen{GLFW.Window}, Makie.Scene, MakieCore.Scatter{Tuple{Vector{GeometryBasics.Point{2, Float32}}}}}, ::Dict{UInt64, GLMakie.GLAbstraction.RenderObject}, ::UInt64)@dict.jl:481 cached_robj!(::GLMakie.var"#182#189"{GLMakie.Screen{GLFW.Window}, Makie.Scene, MakieCore.Scatter{Tuple{Vector{GeometryBasics.Point{2, Float32}}}}}, ::GLMakie.Screen{GLFW.Window}, ::Makie.Scene, ::MakieCore.Scatter{Tuple{Vector{GeometryBasics.Point{2, Float32}}}})@drawing_primitives.jl:84 draw_atomic@drawing_primitives.jl:198[inlined] insert!(::GLMakie.Screen{GLFW.Window}, ::Makie.Scene, ::MakieCore.Scatter{Tuple{Vector{GeometryBasics.Point{2, Float32}}}})@drawing_primitives.jl:126 insertplots!(::GLMakie.Screen{GLFW.Window}, ::Makie.Scene)@screen.jl:435 insertplots!(::GLMakie.Screen{GLFW.Window}, ::Makie.Scene)@screen.jl:438 display_scene!(::GLMakie.Screen{GLFW.Window}, ::Makie.Scene)@screen.jl:374 var"#Screen#48"(::Nothing, ::Bool, ::Type{GLMakie.Screen}, ::Makie.Scene, ::GLMakie.ScreenConfig, ::IOContext{IOBuffer}, ::MIME{Symbol("image/png")})@screen.jl:400 GLMakie.Screen(::Makie.Scene, ::GLMakie.ScreenConfig, ::IOContext{IOBuffer}, ::MIME{Symbol("image/png")})@screen.jl:396 var"#getscreen#1012"(::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, ::typeof(Makie.getscreen), ::Module, ::Makie.Scene, ::IOContext{IOBuffer}, ::Vararg{Any})@display.jl:336 getscreen@display.jl:324[inlined] show(::IOContext{IOBuffer}, ::MIME{Symbol("image/png")}, ::Makie.FigureAxisPlot)@display.jl:203 show_richest(::IOContext{IOBuffer}, ::Any)@PlutoRunner.jl:1175 show_richest_withreturned@PlutoRunner.jl:1100[inlined] format_output_default(::Any, ::Any)@PlutoRunner.jl:1000 #format_output#61@PlutoRunner.jl:1017[inlined] #53@PlutoRunner.jl:909[inlined] var"#with_io_to_logs#115"(::Bool, ::Base.CoreLogging.LogLevel, ::typeof(Main.PlutoRunner.with_io_to_logs), ::Main.PlutoRunner.var"#53#56"{Module, Makie.FigureAxisPlot, Dict{Tuple{UInt64, Int64}, Int64}})@PlutoRunner.jl:2424 (::Main.PlutoRunner.var"#119#120"{Bool, Base.CoreLogging.LogLevel, Main.PlutoRunner.var"#53#56"{Module, Makie.FigureAxisPlot, Dict{Tuple{UInt64, Int64}, Int64}}})()@PlutoRunner.jl:2448 with_logstate(::Function, ::Any)@logging.jl:511 with_logger@logging.jl:623[inlined] #with_logger_and_io_to_logs#118@PlutoRunner.jl:2447[inlined] var"#formatted_result_of#50"(::Bool, ::typeof(Main.PlutoRunner.formatted_result_of), ::Base.UUID, ::Base.UUID, ::Bool, ::Vector{String}, ::Nothing, ::Module)@PlutoRunner.jl:908 top-level scope@WorkspaceManager.jl:527 ```

ffreyer commented 5 months ago

Fixed in Makie 0.21, possibly by #3681

ederag commented 5 months ago

Confirmed, thanks !