为什么我的ggplot线看起来很破碎

时间:2017-08-22 19:31:46

标签: r ggplot2

如何平滑我的密度线?线条非常晃动,看起来很破碎。

x = rnorm(1000);

    # overlay histogram, empirical density and normal density
    p0 = qplot(x, geom = 'blank') +   
      geom_line(aes(y = ..density.., colour = 'Empirical'), stat = 'density') +  
      stat_function(fun = dnorm, aes(colour = 'Normal')) +                       
      geom_histogram(aes(y = ..density..), alpha = 0.4) +                        
      scale_colour_manual(name = 'Density', values = c('red', 'blue')) + 
      theme(legend.position = c(0.85, 0.85))

    print(p0)

enter image description here

enter image description here

0 个答案:

没有答案