julia - 如何在不关闭 Julia 环境的情况下清理 Plots (GR)
问题描述
我正在调试一个脚本(Plots.jl
与GKS QtTerm
后端一起使用)。所以我多次运行脚本。当我从终端运行它时bash> julia pointPlacement.jl
,初始化 Julia 和 Plots.jl 需要很长时间(与 python 相比,这是一个很大的不便)。因此,我宁愿让 Julia 保持打开状态并从内部运行脚本,例如julia> include( "pointPlacement.jl" )
grid = [ [ix*0.01 iy*0.01] for ix=1:100, iy=1:100 ]
grid = vcat(ps...)
centers = hexGrid( 2, 0.2 )
using Plots
display(scatter!( grid[:,1], grid[:,2], markersize = 1, markerstrokewidth = 0, aspect_ratio=:equal ))
display(scatter!( centers[:,1], centers[:,2], markersize = 2, markerstrokewidth = 0, aspect_ratio=:equal ))
问题是地块堆积。这是9次运行之后。应该只有 2 个数据集,而不是 18 个:
我想关闭(杀死,摧毁)他们
如果我这样删除!
,它会有所帮助
display(scatter( grid[:,1], grid[:,2], markersize = 1, markerstrokewidth = 0, aspect_ratio=:equal ))
display(scatter!( centers[:,1], centers[:,2], markersize = 2, markerstrokewidth = 0, aspect_ratio=:equal ))
但是,我仍然担心一些垃圾(以前的数字)会留在内存中,并且在我运行脚本 100 倍后 Julia 会崩溃。因此,我想在每次运行脚本时调用一些函数,如clear()
, flush()
, closeAll()
... 或其他...
解决方案
删除!
具有您想要的效果 - 如果您scatter
再次调用,情节就消失了,并且它不在后台的某个地方。
如果您愿意,您可以将绘图存储在变量中并“为了安全”将其覆盖,即
p = scatter(...)
scatter!(p, ...)
,...
你的阴谋论点在哪里。这将显式覆盖p
每个include
.
推荐阅读
- php - Google 云端硬盘访问权限和 API
- matplotlib - fig.savefig 和 jupyter notebook 显示不一致的刻度和元素放置
- json - 查看嵌套节点中的评论 (Firebase)
- python-3.x - Python 错误,Tweepy API 版本 1.1,属性错误
- javascript - 向下滚动页面时图像不断淡入和淡出 - jQuery
- vaadin - 用于 LitElement 的 Vaadin ts 文件 100% 宽度
- sql - 如何将记录总数与匹配条件的记录总数进行比较
- excel - 谷歌表格根据条件获取特定单元格范围的计数和总和
- python - 如何实现模糊粗略最近邻有序加权平均(FRNN-OWA)分类以产生准确度得分和分类报告?
- php - 第三个测试用例 PHP for 循环不增加