简体   繁体   English

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

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

This is the code: 这是代码:

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")`

This is the Plot I am getting: 这是我得到的情节:

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

As shown in this image 如图所示

最终预测,csv文件图像

the x-axis values were default as 1000, 2000 etc and y-axis default values 25, 75, 100 etc. But I want the x-axis values to be changed as respective user_ids (1163, 2080 = in x-axis) and prediction percentage(0.91,0.833 etc = in y-axis) like = 1,2,3 points are showing ranks respective to user_id and percentage. x轴的默认值是1000、2000等,y轴的默认值是25、75、100等。但是我希望将x轴的值更改为相应的user_id(1163、2080 = x轴),并且像1,2,3点一样的预测百分比(0.91,0.833等= y轴)显示了与user_id和百分比相对应的排名。 [1163 rank is 1 with 0.91(91%), 2080 rank is 2 with 0.83(83%)] [1163排名为1,得分为0.91(91%),2080排名为2,得分为0.83(83%)]

我想要这张图所示的情节

As Suggested Suppose iris data set 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
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
so after taking Sepal.Length in x-axis and Sepal.Width in y-axis.
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之后。
I need x-axis labels need to be respective as shown above. 我需要x轴标签需要分别如上所示。 Like x-axis need to be 5.1 4.9 and y-axis need to be 3.5 3.0 with respective species setosa in the plots iris dataset . 像x轴需要为5.1 4.9 ,y轴需要为3.5 3.0并且在鸢尾花数据集中具有相应的setosa种。 Not as in plot 7.0 , 7.5 breaks and 6 , 7 , 8 breaks 与图7.0 , 7.5中断和6 , 7 , 8中断不同

Try this . 尝试这个 。 . .

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