> ggplot()+ + geom_histogram(binwidth = 200,data=data,aes(x=SII,y=..frequency..),alpha = 0.8,colour="gold3",fill="gold3")+ + scale_y_continuous(sec.axis = sec_axis(~.*4000, name = "HR (95%CI) for 2-year all-cause mortality"))+ + geom_line(data=HR, aes(SII,yhat/4000), + linetype="solid",size=1,alpha = 0.7,colour="steelblue1")+ + geom_ribbon(data=HR, + aes(SII,ymin = lower/4000, ymax = upper/4000), + alpha = 0.1,fill="blue")+ + theme_classic()+ + geom_hline(yintercept=1/4000, linetype=2,size=1)+ + geom_vline(xintercept=570,size=1,linetype=2,color = '#d40e8c')+ + geom_vline(xintercept=1000,size=1,linetype=2,color = '#d40e8c')+#查表HR=1对应的age + labs(x="Systemic immune-inflammation index", y="Density")+ + xlim(0,4000)+ + labs(title = " ")+ + theme(plot.title = element_text(hjust = 0.5)) Error in `geom_histogram()`: ! Problem while mapping stat to aesthetics. ℹ Error occurred in the 1st layer. Caused by error in `map_statistic()`: ! Aesthetics must be valid computed stats. ✖ The following aesthetics are invalid: ✖ `y = ..frequency..` ℹ Did you map your stat in the wrong layer? Run `rlang::last_error()` to see where the error occurred. Warning messages: 1: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0. ℹ Please use `linewidth` instead. This warning is displayed once every 8 hours. Call `lifecycle::last_lifecycle_warnings()` to see where this warning was generated. 2: The dot-dot notation (`..frequency..`) was deprecated in ggplot2 3.4.0. ℹ Please use `after_stat(frequency)` instead. This warning is displayed once every 8 hours. Call `lifecycle::last_lifecycle_warnings()` to see where this warning was generated. 3: Removed 70 rows containing non-finite values (`stat_bin()`).
时间: 2024-04-23 16:21:59 浏览: 218
ggplot是图形语法的Python实现。 它不是为了r的ggplot2的一个特征港口 - 尽管GGPLOT2中的伟大伟大,但P
这段代码中出现了一些错误,其中一个是出现了无效的映射。具体而言,`y = ..frequency..` 这个映射是无效的,应该使用 `y = after_stat(frequency)`。另外,也出现了一些警告信息,例如 `size` 映射被弃用了,应该使用 `linewidth`。还有一个警告是有70个行包含了非有限值(`stat_bin()`)。这些问题需要修改才能正常运行代码。
阅读全文