如何删除分散创建的点!在朱莉娅(使用Makie)

noa*_*iwi 6 plot julia makie.jl

我对朱莉娅很陌生。我目前正在开发一个小程序,它需要我绘制一个点并稍后将其删除(每次只会有一个点)。我正在使用 Makie 包来可视化所有内容,但我还没有找到删除点的方法,该点是通过分散(或分散!)绘制的。代码应该如下所示:

scene = scatter([0],[0], color="blue", markersize=10)
pop!(scene.scatter) #command that removes the dot drawn by the above scatter
Run Code Online (Sandbox Code Playgroud)

我发现这个线程(Julia Plotting:删除和修改现有行)显示了一种使用 pop! 删除最后绘制的东西的方法,但此代码不会运行(如果我添加场景作为参数,我会收到错误消息scatter!(scene,...))。

谢谢你的帮助

Bat*_*aBe 3

有一个delete!(ax::Axis, plot::AbstractPlot)方法,但它有点混乱,所以一个例子可能会更清楚:

scene = scatter([0],[0], color="blue", markersize=10)
# FigureAxisPlot instance
# scene.plot is the Scatter instance

points2 = scatter!(2:4, 2:4, color="green", markersize=20)
# Scatter instance

point3 = scatter!([1], [1], color="red", markersize=15)
# Scatter instance

delete!(scene.axis, points2)
# green points removed from plot

delete!(scene.axis, scene.plot)
# original blue point removed from axis,
# but scene.plot doesn't change
Run Code Online (Sandbox Code Playgroud)