Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/70.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 x轴与log10问题一起传输_R_Ggplot2 - Fatal编程技术网

R ggplot x轴与log10问题一起传输

R ggplot x轴与log10问题一起传输,r,ggplot2,R,Ggplot2,我有很多PDF分发号码(附件)。因为按照正常的方式,我无法描绘它。然后我使用log10传输x轴。但是,有没有办法仍然显示原始x轴(不使用log10) 目前的数字是这样的: 部分数据: structure(list(num = 1:30, pert_sales = c(0.020194064, 0.020140418, 0.014049199, 0.012375386, 0.008335432, 0.007140572, 0.006361819, 0.006179615, 0.0050343

我有很多PDF分发号码(附件)。因为按照正常的方式,我无法描绘它。然后我使用log10传输x轴。但是,有没有办法仍然显示原始x轴(不使用log10)

目前的数字是这样的:

部分数据:

structure(list(num = 1:30, pert_sales = c(0.020194064, 0.020140418, 
0.014049199, 0.012375386, 0.008335432, 0.007140572, 0.006361819, 
0.006179615, 0.005034322, 0.004976598, 0.004922225, 0.004602446, 
0.004490266, 0.004264869, 0.0039289, 0.00387972, 0.003612034, 
0.00357951, 0.00337985, 0.00326423, 0.003048265, 0.002862149, 
0.002769482, 0.002764383, 0.002760949, 0.002760627, 0.002721623, 
0.002617593, 0.002405228, 0.002319419)), row.names = c(NA, 30L
), class = "data.frame")

如果您想要一个log10 x轴,使用
scale\u x\u log10()
比在aes中转换数字本身要好得多,因为如果您添加其他aes或限制等,它们也将被转换,还将为您提供原始数据而不是log10的标签。要停止使用科学记数法(1e+01、1e+10等),可以使用天平库中的标签=逗号。因此:

library(scales)
ggplot(data = dist_cdf,aes(x= num, y=pert_sales)) + 
  theme(panel.background = element_rect(fill = "white", colour = "black")) + 
  scale_x_log10(labels = comma)+
          stat_smooth(method = lm, formula = y ~ poly(x, 9), se = FALSE,span = 1.5,size=1.2,colour = "#FF3300",linetype = 1)

要同时显示对数缩放X轴和未缩放X轴吗?谢谢。不,我只希望x轴显示为原始轴(未缩放)。似乎我无法在此上传数据文件:-(看看
?scale_x_continuous
中的选项不起作用,它显示1e+01,1e+10…一些奇怪的东西科学符号
1e+
的意思是
1 x 10^
,所以:
1e+01=10
1e+02=100
,等等。谢谢。但是,x轴仍然不正确。我的意思是“奇怪”与科学符号无关,但x标签的值不正确。正确的x轴应该在1-200000之间,但这种方式是在1-100000之间。我不知道发生了什么。我的代码是正确的,但x标签显示log10(x)的真实值…你确定不是轴变为200000,而是没有断点吗?如果需要,你可以尝试手动将其添加为断点,即
scale\u x\u log10(标签=逗号,断点=c(1*10^c(1:5),2e5))
library(scales)
ggplot(data = dist_cdf,aes(x= num, y=pert_sales)) + 
  theme(panel.background = element_rect(fill = "white", colour = "black")) + 
  scale_x_log10(labels = comma)+
          stat_smooth(method = lm, formula = y ~ poly(x, 9), se = FALSE,span = 1.5,size=1.2,colour = "#FF3300",linetype = 1)