Skip to content

Commit

Permalink
Merge pull request #52 from MakieOrg/la/up_project
Browse files Browse the repository at this point in the history
adds lscene limits example
  • Loading branch information
lazarusA authored Aug 8, 2024
2 parents e446e58 + ee859e4 commit 627b2e4
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 14 deletions.
1 change: 1 addition & 0 deletions docs/gen_mds.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ function get_files(folders)
"textScatterLines.jl",
"gott_azimuthal.jl",
"us_states.jl",
"gapminder.jl",
])

fpaths = "$(f)/" .* names
Expand Down
1 change: 1 addition & 0 deletions docs/src/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ const viteConfig = defineViteConfig({
{ text: 'RRGraph3D',link: '/examples/3d/mscatters/RRGraph3D' },
{ text: 'SSAO_meshscatter',link: '/examples/3d/mscatters/SSAO_meshscatter' },
{ text: 'SSAO_mgrid',link: '/examples/3d/mscatters/SSAO_mgrid' },
{ text: 'LScene limits',link: '/examples/3d/mscatters/lscene_limits' },
],
},
{
Expand Down
17 changes: 11 additions & 6 deletions examples/3d/meshes/isosurfaces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,19 @@ using GLMakie
using Meshing, GeometryBasics
GLMakie.activate!()

isoval = 100
algo = MarchingCubes(iso=isoval, insidepositive=false)
function show_isosurface(f,h,ξ; color=(:dodgerblue,0.5), isoval=100)
algo = MarchingCubes(; iso=isoval)

function show_isosurface(f,h,ξ; color=(:dodgerblue,0.5))
s = [h(x,y,z) for x in ξ, y in ξ, z in ξ] .+ isoval
mc = GeometryBasics.Mesh(s, algo)

return mesh(f, normal_mesh(mc); color,

## generate the mesh using marching cubes

vts, fcs = isosurface(s, algo)

## mc = GeometryBasics.Mesh(s, algo)

return mesh(f, vts, map(v -> GeometryBasics.TriangleFace(v...), fcs);
color,
diffuse = Vec3f0(0.8),
specular = Vec3f0(1.1),
shininess = 30f0,
Expand Down
18 changes: 18 additions & 0 deletions examples/3d/mscatters/lscene_limits.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# ## Sets limits on a LScene

# ![](lscene_limits.png)

using GLMakie
using Random
Random.seed!(1618)
GLMakie.activate!()

fig = Figure()
ax = LScene(fig[1, 1], scenekw = (;
limits=Rect3f(Vec3f(0,0,0),Vec3f(1.5, 1.5, 2.5)))
)
meshscatter!(ax, rand(Point3f, 10); color = :orangered)
meshscatter!(ax, rand(Point3f, 10) .+ Point3f(0,0,1);
color = :grey25, marker=Rect3f(Vec3f(-0.5), Vec3f(1)))
fig
save("lscene_limits.png", fig); # hide
4 changes: 2 additions & 2 deletions examples/aog/MarketData.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ save("market_data2.svg", current_figure()); # hide
df = DataFrame(ohlc)
pltd = data(df[200:280,:])
plt = pltd * mapping(:timestamp, :Open => "StockChart")
plt *= mapping(fillto=:Close, color = (:Open, :Close) => isless => "Open<Close")
plt *= mapping(color = (:Open, :Close) => isless => "Open<Close") # fillto=:Close, because of this, the plot is wrong
plt *= visual(BarPlot)

with_theme(theme_dark(), size = (800,500)) do
draw(plt, palettes =(; color = [:deepskyblue, :firebrick3]))
draw(plt, scales(Color = (; palette = [:deepskyblue, :firebrick3])))
end

save("market_data3.svg", current_figure()); # hide
Expand Down
3 changes: 2 additions & 1 deletion examples/aog/density_ridges.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ save("densityridges1.png", current_figure()); # hide
p_len = data(penguins)
## p_len = AoG.density()
p_len *= mapping(:flipper_length_mm, color=:species)
p_len *= visual(AoG.Density, direction=:y, offset = 1.0,
p_len *= AoG.density()
p_len *= visual(direction=:y, offset = 1.0, # direction is not working!
alpha = 0.2, strokewidth = 1.5, strokecolor = :grey20)
draw(p_len)

Expand Down
4 changes: 2 additions & 2 deletions examples/aog/penguinsAoG.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ p_len = data(penguins)
p_len *= mapping(:flipper_length_mm => (t -> t / 10) => "flipper length (cm)",
:bill_length_mm => (t -> t / 10) => "bill length (cm)")
## declare the grouping and the respective visual attribute
p_len *= mapping(color=:species, marker=:species)
p_len *= mapping(color=:species)

with_theme(theme_ggplot2(),size = (600,400), palette=palette, Scatter=(cycle=cycle,)) do
draw(p_len + p_len * linear();
draw(p_len * mapping(marker=:species) + p_len * linear();
axis = (; title="Flipper and bill length"))
end

Expand Down
6 changes: 3 additions & 3 deletions examples/aog/textScatterLines.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ d = DataFrame(name = repeat(["A","B","C","D","E","F"], inner=4),
time=repeat([0,1,3,6], outer=6), value = rand(24));

pSL = data(d)
pSL *= mapping(:time, :value, color = :name, #text = :name => verbatim # now is not working :(
)
pSL *= visual(ScatterLines) # + visual(Makie.Text, align = (:center, :bottom))
pSL *= mapping(:time, :value)
pSL *= mapping(color = :name) * visual(ScatterLines) +
mapping(color = :name, text = :name => verbatim) * visual(Makie.Text, align = (:center, :bottom))
with_theme(theme_ggplot2(), size = (600,400)) do
draw(pSL)
end
Expand Down

0 comments on commit 627b2e4

Please sign in to comment.