Reputation: 25703
When plotting a function (as opposed to numerical data), how can we set the number of sample points (i.e. the number of distinct x coordinates where the function is computed)? Importantly, where can I find this information in the documentation?
Example:
plot(x -> sin(1/x), 0.001, 1)
For a useful plot in the 0–0.25 range we need many more points.
Upvotes: 2
Views: 282
Reputation: 181
The number of sampling points can indeed be specified:
plot(y=[x->sin(1/x)], xmin=[0.001], xmax=[1], Stat.func(1000), Geom.line)
You can find Stat.func
in the Gadfly docs here:
http://gadflyjl.org/stable/lib/statistics/#Gadfly.Stat.func.
Note you can write either Stat.func(num_samples=1000)
or Stat.func(1000)
, since there is only one argument.
Upvotes: 2
Reputation: 9608
One way you can do it is:
using Gadfly;
X=1e-6:1e-6:1.0
plot(x=X, y=X .|> x -> sin(1/x), Geom.line)
or you may like this version more
using Gadfly;
X=[1/z for z=300.0:-0.05:1.0]
plot(x=X, y=X .|> x -> sin(1/x), Geom.line)
To get a docu, just do
?plot
or when you want to look at the code
methods(plot)
Upvotes: 4