如何使用ggplot和xlim()提高轴分辨率

时间:2019-03-01 09:22:12

标签: r ggplot2

我正在尝试通过HPLC分离3种化合物的科学实验模拟概况。

我正在用ggplot()绘制峰,但是在x轴上的分辨率确实很差。如何增加ggplot在x轴上使用的点数?

我尝试使用tibble(x = seq(0, 9, 0.005))作为输入数据,但没有任何变化。

当前输出:

peaks <- list(p2 = list(name = "peak 1", tr = 2.5, sigma = 0.00873037869711973, 
    k = 0.25), p5 = list(name = "peak 2", tr = 5, sigma = 0.0174607573942395, 
    k = 1.5), p7 = list(name = "peak 3", tr = 7, sigma = 0.0244450603519352, 
    k = 2.5))

ggplot(tibble(x = 0), aes(x = x)) +
  stat_function(fun = function(x) rowSums(mapply(dnorm,
                                                 mean = sapply(peaks, function(x) x$tr), 
                                                 sd = sapply(peaks, function(x) x$sigma),
                                                 MoreArgs = list(x = x)))) + 
  xlim(0, 9) +
  ylim(0, 50) +
  theme_classic()

enter image description here

thanks Roland

所需的输出:

enter image description here

这是通过数据帧完成的,但我尽可能使用stat_function()方法。谢谢。

0 个答案:

没有答案
相关问题