r - ggplot2 plot of trigonometric function looks jagged -
the curves of trigonometric function plotted 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 jagged plot:
but expecting more smooth plot this:
how 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') 


Comments
Post a Comment