Reputation: 6117
The curves of trigonometric function plotted with ggplot2 looks jagged.
library(ggplot2)
ggplot( data.frame( x = c(-0.2,0.2)), aes( x = x)) +
stat_function( fun = function(x) cos( pi/x) , geom = "line")
Gives this jagged plot:
But I was expecting a more smooth plot like this:
Upvotes: 2
Views: 495
Reputation: 23099
How about this?
library(ggplot2)
ggplot(data.frame( x = c(-2.5,2.5)), aes( x = x)) +
stat_function(fun = function(x) ifelse(x!=0, cos(pi/x), 0),
geom = "line", n=5000, col='blue')
Upvotes: 5