gpt4 book ai didi

julia - Gadfly:绘制函数时如何设置采样点数?

转载 作者:行者123 更新时间:2023-12-02 17:16:13 41 4
gpt4 key购买 nike

绘制函数(与数值数据相反)时,我们如何设置样本点的数量(即计算函数的不同 x 坐标的数量)?重要的是,我可以在文档中的何处找到此信息?

例子:

plot(x -> sin(1/x), 0.001, 1)

Plot with insufficient sampling

要在 0–0.25 范围内绘制有用的图,我们需要更多的点。

最佳答案

一种方法是:

using Gadfly;
X=1e-6:1e-6:1.0
plot(x=X, y=X .|> x -> sin(1/x), Geom.line)

或者你可能更喜欢这个版本

using Gadfly;
X=[1/z for z=300.0:-0.05:1.0]
plot(x=X, y=X .|> x -> sin(1/x), Geom.line)

要获取文档,只需执行

?plot

或者当你想看代码的时候

methods(plot)

关于julia - Gadfly:绘制函数时如何设置采样点数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46132148/

41 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com