作者rickydai888 (暗夜流光)
看板R_Language
标题[问题] lattice绘图问题
时间Mon May 13 15:49:54 2019
各位板友大家好,首次发文,是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://webptt.com/cn.aspx?n=bbs/R_Language/M.1557733796.A.C2D.html
1F:→ andrew43: dotplot() 里的 Type 改成05/13 16:16
2F:→ andrew43: factor(Type, levels = c("Populist", "Mixed", "Nonpop05/13 16:17
3F:→ andrew43: ulist"))05/13 16:17
4F:→ andrew43: 这招在类别型座标轴很常用05/13 16:20
顺利的跑出来了 感谢您的协助!
※ 编辑: rickydai888 (111.250.88.42), 05/13/2019 16:37:28
5F:推 rocusauk520: SigmaPlot其实也不错用xd 05/15 13:52