在ggplot2中叠加密度图的警告信息。

时间:2021-08-01 14:58:33

I'm trying to do a density plot of two datasets (of different size) by writing:

我想通过写两个数据集的密度图(不同大小)

data1 <- data.frame(dens = log2(c(tmm.th[,1],bidrar_mest[,1]))
                  , lines = c(rep("all",61893),rep("loaded",50) ))

ggplot(data1, aes(x = dens, fill = lines)) + geom_density(alpha = 0.5)

I get a nice plot showing that the smaller dataset has higher values but I also get a warning message saying:

我得到了一个很好的图,显示较小的数据集具有更高的值,但我也得到了一个警告消息:

Warning message: Removed 35492 rows containing non-finite values
(stat_density).

Can someone explain why and how to get rid of that?

有人能解释一下为什么以及如何摆脱它吗?

1 个解决方案

#1


2  

As @Ant and @alexwhan have already pointed out, the problem could be due to:

@Ant和@alexwhan已经指出,问题可能是:

  • points that are negative or equal to zero. In the second case the log-transform would give as output -Inf, which is then dicarded in the analyisis.
  • 点是负的或等于零的。在第二种情况下,log-transform将给出输出-Inf,然后在分析中对其进行dicarisis。
  • points that are out of the range that it is possible to prescribe.
  • 这些点超出了可以规定的范围。

Since in your case the limit in the x- or y-axis is not set a priori, I would say that the reason is the fisrt one.

因为在你的例子中x轴或y轴的极限不是先验的,我认为原因是第一个裂缝。

Please, see the following links for further explanations:

详情请参阅以下连结:

I hope this can help.

我希望这能有所帮助。

#1


2  

As @Ant and @alexwhan have already pointed out, the problem could be due to:

@Ant和@alexwhan已经指出,问题可能是:

  • points that are negative or equal to zero. In the second case the log-transform would give as output -Inf, which is then dicarded in the analyisis.
  • 点是负的或等于零的。在第二种情况下,log-transform将给出输出-Inf,然后在分析中对其进行dicarisis。
  • points that are out of the range that it is possible to prescribe.
  • 这些点超出了可以规定的范围。

Since in your case the limit in the x- or y-axis is not set a priori, I would say that the reason is the fisrt one.

因为在你的例子中x轴或y轴的极限不是先验的,我认为原因是第一个裂缝。

Please, see the following links for further explanations:

详情请参阅以下连结:

I hope this can help.

我希望这能有所帮助。