繁体   English   中英

除了R的默认图外,如何更改r中的x轴和y轴值?

[英]How to change x-axis and y-axis value in r other than default plot by R?

这是代码:

ggplot(percent, aes(x = user_id , y = percentage, label = final_rank)) + 
geom_text(check_overlap = TRUE, nudge_y = 5,nudge_x = 1,size = 5, color = "blue") + 
geom_point(color = "red")`

这是我得到的情节:

用户ID和预测百分比之间的关系图

如图所示

最终预测,csv文件图像

x轴的默认值是1000、2000等,y轴的默认值是25、75、100等。但是我希望将x轴的值更改为相应的user_id(1163、2080 = x轴),并且像1,2,3点一样的预测百分比(0.91,0.833等= y轴)显示了与user_id和百分比相对应的排名。 [1163排名为1,得分为0.91(91%),2080排名为2,得分为0.83(83%)]

我想要这张图所示的情节

如建议假设虹膜数据集head(iris)
Sepal.Length Sepal.Width Petal.Length Petal.Width Species 1 5.1 3.5 1.4 0.2 setosa 2 4.9 3.0 1.4 0.2 setosa 3 4.7 3.2 1.3 0.2 setosa 4 4.6 3.1 1.5 0.2 setosa 5 5.0 3.6 1.4 0.2 setosa 6 5.4 3.9 1.7 0.4 setosa
head(iris)
Sepal.Length Sepal.Width Petal.Length Petal.Width Species 1 5.1 3.5 1.4 0.2 setosa 2 4.9 3.0 1.4 0.2 setosa 3 4.7 3.2 1.3 0.2 setosa 4 4.6 3.1 1.5 0.2 setosa 5 5.0 3.6 1.4 0.2 setosa 6 5.4 3.9 1.7 0.4 setosa
head(iris)
Sepal.Length Sepal.Width Petal.Length Petal.Width Species 1 5.1 3.5 1.4 0.2 setosa 2 4.9 3.0 1.4 0.2 setosa 3 4.7 3.2 1.3 0.2 setosa 4 4.6 3.1 1.5 0.2 setosa 5 5.0 3.6 1.4 0.2 setosa 6 5.4 3.9 1.7 0.4 setosa
因此在x轴取Sepal.Length和y轴取Sepal.Width之后。
我需要x轴标签需要分别如上所示。 像x轴需要为5.1 4.9 ,y轴需要为3.5 3.0并且在鸢尾花数据集中具有相应的setosa种。 与图7.0 , 7.5中断和6 , 7 , 8中断不同

尝试这个 。

library(tidyvsere)

iris %>%
  filter(Species == "setosa") %>%
    ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width)) + 
    geom_point() +
    scale_x_continuous(breaks = iris$Sepal.Length)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM