覆盖两个stat_density图

时间:2019-11-01 18:45:24

标签: r ggplot2

我想覆盖两个一维数组中的两个密度图。我都需要对数-对数比例。 这些文件仅包含数字列表(1.000.000),它们都是从非常相似的特定分布中产生的,并且在4000左右有一个小峰值,因此一个或两个轴上的对数刻度。

someVar

两个文件之一,它们都很相似

https://drive.google.com/file/d/1HEHWZR0Gl6YB1tLFF4WjXFp5ZoB-DrlW/view?usp=drivesdk

这是我仅用于一个数组的内容:

> prova
   [1]    1.106172    2.617064    1.778360    1.372890    5.334664    2.019493
   [7]    1.174879    1.371897    4.018011    1.220845    3.631309    1.437586 ...

我试图复制在另一个答案中看到的解决方案,但是在这种情况下,奇怪的是图形不在对数对数范围内。

#Packages
library(tidyverse)
library(plotly)
library(ggplot2)
library(scales)
library(ggforce)

prova <-readRDS("probcond1.rds")
prova1 <-readRDS("probpoly.rds")
dfGamma <-data.frame(prova)

g <- ggplot(dfGamma, aes(x=prova)) +
  stat_density(aes(y=..count..), color="black", fill="blue", alpha=0.3) + scale_x_continuous(breaks=c(0,1,2,3,4,5,10,30,100,300,1000,2000,3000,4000,5000), trans="log1p", expand=c(0,0)) + scale_y_continuous(expand=c(0,0), trans="log1p") + theme_bw()

我对R很陌生,我不确定如何从两个列表中构建data.frame以及如何操作它。谢谢您的耐心等候。

0 个答案:

没有答案