Comments (4)
A workaround might be to plot line segments as cylinders, but then I encounter other issues, cf. #3512 and #3513.
If those two are fixed before this issue, then here is an alternative to linesegments!
that uses cylinders:
using WGLMakie, LinearAlgebra
function linesegmenttubes!(ax, pts; tubewidth, quality=32, kwargs...)
marker = Makie._mantle(Makie.Point3f0(0, 0, -1/2), Makie.Point3f0(0, 0, 1/2), 1/2, 1/2, quality)
@assert iseven(length(pts))
x = pts[begin:2:end-1]
y = pts[begin+1:2:end]
pos = @. Makie.Point3f0((x + y) / 2)
dirs = @. Makie.Vec3f0(y - x)
markersize = [Makie.Vec3f0(tubewidth, tubewidth, norm(dir)) for dir in dirs]
rotation = normalize.(dirs)
Makie.meshscatter!(ax, pos; markersize, rotation, marker, kwargs...)
end
fig = Makie.Figure()
ax = Makie.LScene(fig[1, 1])
pts = [[0, 0, 0], [1, 0, 1], [2, 0, 1], [2, -1, 0]]
color = [:red, :blue]
linesegmenttubes!(ax, pts; tubewidth=0.1, quality=12, color)
Makie.DataInspector(ax; indicator_color=:gray)
from makie.jl.
Thanks a lot for looking into it. It's close, but there still seems to be a problem. Consider this slightly more complicated script:
begin
fig = Figure()
ax = LScene(fig[1,1])
segments = [Point3f(1,0,0), Point3f(0,1,0), Point3f(0, 0, 1), Point3f(1, 0, 1)]
color = [:red, :blue]
inspector_label(_, i, _) = ["hello", "world", "nice", "day"][mod1(i, 4)]
linesegments!(ax, segments; color, inspectable=true, inspector_label)
DataInspector(ax)
fig
end
- GLMakie behavior: Inspecting the red line prints "world" and inspecting the blue line prints "day". Tooltip location follows mouse.
- WGLMakie behavior: Inspecting the blue line almost works. Sometimes the tooltip follows the cursor and prints "day" like in GLMakie. Sometimes the tooltip snaps to the top-right and prints instead "nice" (see two images below). Inspecting the red line throws an error with the following stack trace:
┌ Warning: Error in window event callback
│ exception =
│ BoundsError: attempt to access 4-element Vector{Point{3, Float32}} at index [0:1]
│ Stacktrace:
│ [1] throw_boundserror(A::Vector{Point{3, Float32}}, I::Tuple{UnitRange{Int64}})
│ @ Base ./abstractarray.jl:734
│ [2] checkbounds
│ @ Base ./abstractarray.jl:699 [inlined]
│ [3] getindex(A::Vector{Point{3, Float32}}, I::UnitRange{Int64})
│ @ Base ./array.jl:973
│ [4] position_on_plot(plot::LineSegments{Tuple{Vector{Point{3, Float32}}}}, idx::Int64, ray::Makie.Ray; apply_transform::Bool)
│ @ Makie ~/.julia/packages/Makie/Qvk4f/src/interaction/ray_casting.jl:254
│ [5] position_on_plot
│ @ ~/.julia/packages/Makie/Qvk4f/src/interaction/ray_casting.jl:253 [inlined]
│ [6] position_on_plot(plot::LineSegments{Tuple{Vector{Point{3, Float32}}}}, idx::Int64; apply_transform::Bool)
│ @ Makie ~/.julia/packages/Makie/Qvk4f/src/interaction/ray_casting.jl:235
│ [7] position_on_plot
│ @ ~/.julia/packages/Makie/Qvk4f/src/interaction/ray_casting.jl:234 [inlined]
│ [8] show_data(inspector::DataInspector, plot::LineSegments{Tuple{Vector{Point{3, Float32}}}}, idx::Int64)
│ @ Makie ~/.julia/packages/Makie/Qvk4f/src/interaction/inspector.jl:518
│ [9] show_data_recursion(inspector::DataInspector, plot::LineSegments{Tuple{Vector{Point{3, Float32}}}}, idx::Int64)
│ @ Makie ~/.julia/packages/Makie/Qvk4f/src/interaction/inspector.jl:339
│ [10] on_hover(inspector::DataInspector)
│ @ Makie ~/.julia/packages/Makie/Qvk4f/src/interaction/inspector.jl:307
│ [11] (::Makie.var"#1236#1240"{DataInspector})(::Tuple{Float64, Float64})
│ @ Makie ~/.julia/packages/Makie/Qvk4f/src/interaction/inspector.jl:280
│ [12] #invokelatest#2
│ @ Base ./essentials.jl:887 [inlined]
│ [13] invokelatest
│ @ Base ./essentials.jl:884 [inlined]
│ [14] notify
│ @ Observables ~/.julia/packages/Observables/YdEbO/src/Observables.jl:206 [inlined]
│ [15] setindex!(observable::Observable, val::Any)
│ @ Observables ~/.julia/packages/Observables/YdEbO/src/Observables.jl:123
│ [16] (::WGLMakie.var"#58#60"{Dict{Any, Any}, Scene, Events})()
│ @ WGLMakie ~/.julia/packages/WGLMakie/t9g1u/src/events.jl:57
└ @ WGLMakie ~/.julia/packages/WGLMakie/t9g1u/src/events.jl:109
Two snapshots from WGLMakie backend shown below:
![image](https://private-user-images.githubusercontent.com/290205/293437666-555c7bef-0de1-4774-8202-1fe8dca2f0d7.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MDUyMzAyNDEsIm5iZiI6MTcwNTIyOTk0MSwicGF0aCI6Ii8yOTAyMDUvMjkzNDM3NjY2LTU1NWM3YmVmLTBkZTEtNDc3NC04MjAyLTFmZThkY2EyZjBkNy5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwMTE0JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDExNFQxMDU5MDFaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0zMjkzNDQ0ODY1YzFlNTM5ZDE1OTgzMTZlOGZmMWQxOWNkYjY3NmQ4YTQwMDQ2YWY2ZDFiMjdmZWU5MmE3NzQ1JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.BnACBQhJCa8ybRV-Tv2xY_CvzEju_LGqGIeUQDgZzvk)
![image](https://private-user-images.githubusercontent.com/290205/293437650-a143f688-d58f-4882-9c43-3fe7bda202a2.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MDUyMzAyNDEsIm5iZiI6MTcwNTIyOTk0MSwicGF0aCI6Ii8yOTAyMDUvMjkzNDM3NjUwLWExNDNmNjg4LWQ1OGYtNDg4Mi05YzQzLTNmZTdiZGEyMDJhMi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwMTE0JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDExNFQxMDU5MDFaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT02N2FjZTYwYmEwOGNjMGMzODU4M2Q3NDkxMjQ1NmI5MWFiODdmMjgyOWI2Y2ZhM2ZkYWM0ODVhY2ViMzkyYzBiJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.6s1qhw_wOPYH4r_S7HsAHa51AIZiHeK2Ih26Faqr0oY)
from makie.jl.
I think WGLMakie behaves correct now for this simpler example:
begin
segments = Point2f[(0, 0), (0, 1), (1, 0), (1, 2)]
color = [:red, :black, :blue, :black]
inspector_label(_, i, _) = (@show Int(i); ["hello", "world", "nice", "day"][mod1(i, 4)])
fig, ax, pl = linesegments(segments; color, inspector_label, linewidth=10)
DataInspector(ax)
display(fig; backend=WGLMakie)
end
It feels a bit buggy, that the index for the segment start only gets picked at the very beginning of the line, it should be more in the middle. Will need to look at the shader to see if we can fix that.
The out of bounds error you're getting sounds like you checked out the branch too early, I pushed a fix for that just before merging.
For GLMakie, it only gives indices for the ends of the line, not sure if we can change that right away.
from makie.jl.
Thanks, I can confirm the bounds error is gone! To elaborate on the remaining bug, it seems to either "detect" the line itself, correctly (index 2) or some other object marking the beginning of the line, at the wrong position (index 1). Please see attached movie in the context of your 2D example.
2D_example.mov
from makie.jl.
Related Issues (20)
- Recipes broken on 0.20.x HOT 1
- `contourf!()` gives `StackOverflowError` on `Array{Union{Float64,Missing}}` HOT 1
- WGLMakie `DataInspector` is missing some font characters HOT 4
- WGLMakie error in window event callback
- CairoMakie `display` mutates package directory HOT 2
- GLMakie precompilation warning in Julia 1.10
- Scatter! does not render a section of the screen during animation HOT 1
- DataInspector still shows transformed coordinated for log scale, hline HOT 1
- Overlay multiple contours on a single plot HOT 2
- Provide a method to plot a sample (or calibration) arrow
- Legend not working when using custom colorrange
- `rainclouds` no longer displays category labels on x-axis HOT 1
- WGLMakie now throws an error if no screen available HOT 2
- Dead link in GLMakie/README.md HOT 3
- Deleting a plot removes listener HOT 2
- Zooming wireframe shows extra lines, regression Makie 0.19 -> 0.20 HOT 1
- Issues with h/vspan and h/hspan in log space HOT 3
- Last and first points of `lines` get interpolated when there is a lot of points (GLMakie) HOT 3
- Issue using scatter and line in 3d together with Vector{Union{Float64,Missing}} HOT 3
- `DataInspector` overcounts the point number in `stairs` plots (GLMakie) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from makie.jl.