Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R ggplot:根据整个数据集,在保持正常化的同时,绘制CDF的剪切图_R_Ggplot2 - Fatal编程技术网

R ggplot:根据整个数据集,在保持正常化的同时,绘制CDF的剪切图

R ggplot:根据整个数据集,在保持正常化的同时,绘制CDF的剪切图,r,ggplot2,R,Ggplot2,我有以下结构的数据框: x series 11.1 "without restraints" 9.8 "without restraints" 7.0 "restraints" ... 我想绘制按序列分组的数据的累积分布函数。一般来说,它与命令配合得很好 ggplot(data = df, aes(x = x, col = series)) + stat_ecdf(geom = "smooth") + sc

我有以下结构的数据框:

   x                   series
11.1     "without restraints"
 9.8     "without restraints"
 7.0             "restraints"
 ...
我想绘制按序列分组的数据的累积分布函数。一般来说,它与命令配合得很好

ggplot(data = df, aes(x = x, col = series)) + stat_ecdf(geom = "smooth") + scale_x_continuous(limits=c(min_x, max_x))
x值的范围从3.7到20左右。如果我将限制设置为3和25,则输出如下 但是,如果我将限制设置为3和10,则输出为,并且分数/密度现在根据3到10范围内的数据集进行计算。有没有一种方法,我用整个数据集的比例来绘制它,这样密度就相对于完整的数据集给出了(因此,在x值为10时,密度应该在0.13左右)


谢谢您的帮助。

您可以使用
coord\u cartesian

+ coord_cartesian(xlim = c(3, 10))
scale\u x\u continuous
中规定的限制相反,
coord\u cartesian
使用整个数据集

从笛卡尔坐标

+ coord_cartesian(xlim = c(3, 10))
在坐标系上设置限制将缩放绘图(就像使用放大镜查看),并且不会像在比例上设置限制那样更改基础数据

整个代码:

ggplot(data = df, aes(x = x, col = series)) + 
 stat_ecdf(geom = "smooth") + 
 coord_cartesian(xlim = c(min_x, max_x))

谢谢,这很有帮助。很抱歉我迟到了,我以为我已经接受了你的答案。真的很高兴我在这里找到了你的答案,尽管我参加聚会已经很晚了。谢谢