簡體   English   中英

如何在R中將數字設置為x軸

[英]how to set numbers as x-axis in R

我想制作一個條形圖並嘗試將這些數字添加為x軸,但它使第10項和“> 10”移位:

plot_ly(x = c(1, 2,3,4,5,6,7,8,9,10,'>10'),
        y = c(5, 11, 23,14,21,18,20,19,12,31,21),
        name = "dd",
        type = "bar", 
        xaxis = list(title ="tr"), 
        yaxis = list(title = "cc")) 

我得到以下圖:

在此處輸入圖片說明

指定xaxis的布局對我有用:

plot_ly(x = c(1, 2,3,4,5,6,7,8,9,10,'>10'),
        y = c(5, 11, 23,14,21,18,20,19,12,31,21),
        name = "dd",
        type = "bar", 
        xaxis = list(title ="tr"), 
        yaxis = list(title = "cc")) %>%
  layout(title = "Features",
         xaxis = list(type = "category",
                      title = "tr"),
         yaxis = list(title = "cc"))

情節v2

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM