![](/img/trans.png)
[英]How to plot % positive cases (y-axis) by collection date (x-axis) and by other factors (R)?
[英]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")`
這是我得到的情節:
如圖所示
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 setosahead(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 setosahead(iris)
因此在x軸取Sepal.Length和y軸取Sepal.Width之后。 我需要x軸標簽需要分別如上所示。 像x軸需要為
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 setosa5.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.