Search code examples
rplotgranularity

Change granularity of function plot to make plot look smooth


Using the R plot function to plot another function, how can I increase the granularity so that the graph looks smooth? I.e. something analogous to seq(by=.001)?

plot(sin, to=100)

plot(sin, to=100) has jagged edges


Solution

  • Try plot(curve(sin, ...)), and then set n= to your desired resolution.

    curve(sin, from=0, to=100)         # default, n=101
    curve(sin, from=0, to=100, n=1001)
    

    curve with n=101

    curve with n=1001