看板 R_Language 關於我們 聯絡資訊
各位板友大家好,首次發文,是R的新手,想請教以下問題,另外手機排版傷眼抱歉! 我要把以下資料: library(dplyr) DT <- tibble(Country=c("Spain", "France", "Germany","Italy", "Sweden"),Popul ist=c(52,58,65,50, 73),Mixed=c(70,72,70,65,81),Nonpopulist=c(85,84,88,68, 90 )) 繪製成點狀圖,而我的語法如下: DT_tidy<-gather(data = DT,key = "Type", value = "Percentage",Populist, Mixed ,Nonpopulist) library(lattice) DT_tidy2<-as.data.frame(DT_tidy) NDT_tidy2<-dotplot( Percentage~Type ,DT_tidy2, group=Country,type = "o") update(NDT_tidy2, auto.key=list(points=T, lines=T)) 本來按照範例的圖片,應該會長這個樣子: https://i.imgur.com/xQBDUQm.jpg
而我自己預期繪圖結果應長這樣: https://i.imgur.com/hfIK4K8.jpg
但是結果跑出來變成這樣: https://i.imgur.com/7mRGN2P.jpg
我想要調整X軸的順序,讓它符合我預想的圖像,但是怎麼調整都失敗,所以想請教各位 這個要如何修改,非常感謝大家! -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 111.250.88.42 ※ 文章網址: https://www.ptt.cc/bbs/R_Language/M.1557733796.A.C2D.html
andrew43: dotplot() 裡的 Type 改成05/13 16:16
andrew43: factor(Type, levels = c("Populist", "Mixed", "Nonpop05/13 16:17
andrew43: ulist"))05/13 16:17
andrew43: 這招在類別型座標軸很常用05/13 16:20
順利的跑出來了 感謝您的協助! ※ 編輯: rickydai888 (111.250.88.42), 05/13/2019 16:37:28
rocusauk520: SigmaPlot其實也不錯用xd 05/15 13:52