3 回答
TA贡献2019条经验 获得超9个赞
Example.Data<- data.frame(matrix(vector(), 0, 3, dimnames=list(c(), c("Value", "Variable", "Fill"))), stringsAsFactors=F)Example.Data[1, ] <- c(45, 'Horizontal Pattern','Horizontal Pattern' )Example.Data[2, ] <- c(65, 'Vertical Pattern','Vertical Pattern' )Example.Data[3, ] <- c(89, 'Mesh Pattern','Mesh Pattern' )HighlightDataVert<-Example.Data[2, ]HighlightHorizontal<-Example.Data[1, ]HighlightMesh<-Example.Data[3, ]HighlightHorizontal$Value<-as.numeric(HighlightHorizontal$Value)Example.Data$Value<-as.numeric(Example.Data$Value)HighlightDataVert$Value<-as.numeric(HighlightDataVert$Value)HighlightMesh$Value<-as.numeric(HighlightMesh$Value)HighlightHorizontal$Value<-HighlightHorizontal$Value-5HighlightHorizontal2<-HighlightHorizontal HighlightHorizontal2$Value<-HighlightHorizontal$Value-5HighlightHorizontal3<-HighlightHorizontal2 HighlightHorizontal3$Value<-HighlightHorizontal2$Value-5HighlightHorizontal4<-HighlightHorizontal3 HighlightHorizontal4$Value<-HighlightHorizontal3$Value-5HighlightHorizontal5<-HighlightHorizontal4 HighlightHorizontal5$Value<-HighlightHorizontal4$Value-5HighlightHorizontal6<-HighlightHorizontal5 HighlightHorizontal6$Value<-HighlightHorizontal5$Value-5HighlightHorizontal7<-HighlightHorizontal6 HighlightHorizontal7$Value<-HighlightHorizontal6$Value-5HighlightHorizontal8<-HighlightHorizontal7 HighlightHorizontal8$Value<-HighlightHorizontal7$Value-5HighlightMeshHoriz<-HighlightMesh HighlightMeshHoriz$Value<-HighlightMeshHoriz$Value-5HighlightMeshHoriz2<-HighlightMeshHoriz HighlightMeshHoriz2$Value<-HighlightMeshHoriz2$Value-5HighlightMeshHoriz3<-HighlightMeshHoriz2 HighlightMeshHoriz3$Value<-HighlightMeshHoriz3$Value-5HighlightMeshHoriz4<-HighlightMeshHoriz3 HighlightMeshHoriz4$Value<-HighlightMeshHoriz4$Value-5HighlightMeshHoriz5<-HighlightMeshHoriz4 HighlightMeshHoriz5$Value<-HighlightMeshHoriz5$Value-5HighlightMeshHoriz6<-HighlightMeshHoriz5 HighlightMeshHoriz6$Value<-HighlightMeshHoriz6$Value-5HighlightMeshHoriz7<-HighlightMeshHoriz6 HighlightMeshHoriz7$Value<-HighlightMeshHoriz7$Value-5HighlightMeshHoriz8<-HighlightMeshHoriz7 HighlightMeshHoriz8$Value<-HighlightMeshHoriz8$Value-5HighlightMeshHoriz9<-HighlightMeshHoriz8 HighlightMeshHoriz9$Value<-HighlightMeshHoriz9$Value-5HighlightMeshHoriz10<-HighlightMeshHoriz9 HighlightMeshHoriz10$Value<-HighlightMeshHoriz10$Value-5HighlightMeshHoriz11<-HighlightMeshHoriz10 HighlightMeshHoriz11$Value<-HighlightMeshHoriz11$Value-5HighlightMeshHoriz12<-HighlightMeshHoriz11 HighlightMeshHoriz12$Value<-HighlightMeshHoriz12$Value-5HighlightMeshHoriz13<-HighlightMeshHoriz12 HighlightMeshHoriz13$Value<-HighlightMeshHoriz13$Value-5HighlightMeshHoriz14<-HighlightMeshHoriz13 HighlightMeshHoriz14$Value<-HighlightMeshHoriz14$Value-5HighlightMeshHoriz15<-HighlightMeshHoriz14 HighlightMeshHoriz15$Value<-HighlightMeshHoriz15$Value-5HighlightMeshHoriz16<-HighlightMeshHoriz15 HighlightMeshHoriz16$Value<-HighlightMeshHoriz16$Value-5HighlightMeshHoriz17<-HighlightMeshHoriz16 HighlightMeshHoriz17$Value<-HighlightMeshHoriz17$Value-5ggplot(Example.Data, aes(x=Variable, y=Value, fill=Fill)) + theme_bw() + #facet_wrap(~Product, nrow=1)+ #Ensure theme_bw are there to create borders theme(legend.position = "none")+ scale_fill_grey(start=.4)+ #scale_y_continuous(limits = c(0, 100), breaks = (seq(0,100,by = 10)))+ geom_bar(position=position_dodge(.9), stat="identity", colour="black", legend = FALSE)+ geom_bar(data=HighlightDataVert, position=position_dodge(.9), stat="identity", colour="black", size=.5, width=0.80)+geom_bar(data=HighlightDataVert, position=position_dodge(.9), stat="identity", colour="black", size=.5, width=0.60)+ geom_bar(data=HighlightDataVert, position=position_dodge(.9), stat="identity", colour="black", size=.5, width=0.40)+ geom_bar(data=HighlightDataVert, position=position_dodge(.9), stat="identity", colour="black", size=.5, width=0.20)+ geom_bar(data=HighlightDataVert, position=position_dodge(.9), stat="identity", colour="black", size=.5, width=0.0) + geom_bar(data=HighlightHorizontal, position=position_dodge(.9), stat="identity", colour="black", size=.5)+ geom_bar(data=HighlightHorizontal2, position=position_dodge(.9), stat="identity", colour="black", size=.5)+ geom_bar(data=HighlightHorizontal3, position=position_dodge(.9), stat="identity", colour="black", size=.5)+ geom_bar(data=HighlightHorizontal4, position=position_dodge(.9), stat="identity", colour="black", size=.5)+ geom_bar(data=HighlightHorizontal5, position=position_dodge(.9), stat="identity", colour="black", size=.5)+ geom_bar(data=HighlightHorizontal6, position=position_dodge(.9), stat="identity", colour="black", size=.5)+ geom_bar(data=HighlightHorizontal7, position=position_dodge(.9), stat="identity", colour="black", size=.5)+ geom_bar(data=HighlightHorizontal8, position=position_dodge(.9), stat="identity", colour="black", size=.5)+ geom_bar(data=HighlightMesh, position=position_dodge(.9), stat="identity", colour="black", size=.5, width=0.80)+ geom_bar(data=HighlightMesh, position=position_dodge(.9), stat="identity", colour="black", size=.5, width=0.60)+ geom_bar(data=HighlightMesh, position=position_dodge(.9), stat="identity", colour="black", size=.5, width=0.40)+ geom_bar(data=HighlightMesh, position=position_dodge(.9), stat="identity", colour="black", size=.5, width=0.20)+ geom_bar(data=HighlightMesh, position=position_dodge(.9), stat="identity", colour="black", size=.5, width=0.0)+ geom_bar(data=HighlightMeshHoriz, position=position_dodge(.9), stat="identity", colour="black", size=.5, fill = "transparent")+geom_bar(data=HighlightMeshHoriz2, position=position_dodge(.9), stat="identity", colour="black", size=.5, fill = "transparent")+ geom_bar(data=HighlightMeshHoriz3, position=position_dodge(.9), stat="identity", colour="black", size=.5, fill = "transparent")+ geom_bar(data=HighlightMeshHoriz4, position=position_dodge(.9), stat="identity", colour="black", size=.5, fill = "transparent")+ geom_bar(data=HighlightMeshHoriz5, position=position_dodge(.9), stat="identity", colour="black", size=.5, fill = "transparent")+ geom_bar(data=HighlightMeshHoriz6, position=position_dodge(.9), stat="identity", colour="black", size=.5, fill = "transparent")+ geom_bar(data=HighlightMeshHoriz7, position=position_dodge(.9), stat="identity", colour="black", size=.5, fill = "transparent")+ geom_bar(data=HighlightMeshHoriz8, position=position_dodge(.9), stat="identity", colour="black", size=.5, fill = "transparent")+ geom_bar(data=HighlightMeshHoriz9, position=position_dodge(.9), stat="identity", colour="black", size=.5, fill = "transparent")+ geom_bar(data=HighlightMeshHoriz10, position=position_dodge(.9), stat="identity", colour="black", size=.5, fill = "transparent")+ geom_bar(data=HighlightMeshHoriz11, position=position_dodge(.9), stat="identity", colour="black", size=.5, fill = "transparent")+ geom_bar(data=HighlightMeshHoriz12, position=position_dodge(.9), stat="identity", colour="black", size=.5, fill = "transparent")+ geom_bar(data=HighlightMeshHoriz13, position=position_dodge(.9), stat="identity", colour="black", size=.5, fill = "transparent")+ geom_bar(data=HighlightMeshHoriz14, position=position_dodge(.9), stat="identity", colour="black", size=.5, fill = "transparent")+ geom_bar(data=HighlightMeshHoriz15, position=position_dodge(.9), stat="identity", colour="black", size=.5, fill = "transparent")+ geom_bar(data=HighlightMeshHoriz16, position=position_dodge(.9), stat="identity", colour="black", size=.5, fill = "transparent")+ geom_bar(data=HighlightMeshHoriz17, position=position_dodge(.9), stat="identity", colour="black", size=.5, fill = "transparent")
fill
fill='transparent'
Example.Data[4,] <- c(20, 'Diagonal Pattern','Diagonal Pattern' )
Diag <- data.frame( x = c(1,1,1.45,1.45), # 1st 2 values dictate starting point of line. 2nd 2 dictate width. Each whole = one background grid y = c(0,0,20,20), x2 = c(1.2,1.2,1.45,1.45), # 1st 2 values dictate starting point of line. 2nd 2 dictate width. Each whole = one background grid y2 = c(0,0,11.5,11.5),# inner 2 values dictate height of horizontal line. Outer: vertical edge lines. x3 = c(1.38,1.38,1.45,1.45), # 1st 2 values dictate starting point of line. 2nd 2 dictate width. Each whole = one background grid y3 = c(0,0,3.5,3.5),# inner 2 values dictate height of horizontal line. Outer: vertical edge lines. x4 = c(.8,.8,1.26,1.26), # 1st 2 values dictate starting point of line. 2nd 2 dictate width. Each whole = one background grid y4 = c(0,0,20,20),# inner 2 values dictate height of horizontal line. Outer: vertical edge lines. x5 = c(.6,.6,1.07,1.07), # 1st 2 values dictate starting point of line. 2nd 2 dictate width. Each whole = one background grid y5 = c(0,0,20,20),# inner 2 values dictate height of horizontal line. Outer: vertical edge lines. x6 = c(.555,.555,.88,.88), # 1st 2 values dictate starting point of line. 2nd 2 dictate width. Each whole = one background grid y6 = c(6,6,20,20),# inner 2 values dictate height of horizontal line. Outer: vertical edge lines. x7 = c(.555,.555,.72,.72), # 1st 2 values dictate starting point of line. 2nd 2 dictate width. Each whole = one background grid y7 = c(13,13,20,20),# inner 2 values dictate height of horizontal line. Outer: vertical edge lines. x8 = c(.8,.8,1.26,1.26), # 1st 2 values dictate starting point of line. 2nd 2 dictate width. Each whole = one background grid y8 = c(0,0,20,20),# inner 2 values dictate height of horizontal line. Outer: vertical edge lines. #Variable = "Diagonal Pattern", Fill = "Diagonal Pattern" )
+geom_path(data=Diag, aes(x=x, y=y),colour = "black")+ # calls co-or for sig. line & draws geom_path(data=Diag, aes(x=x2, y=y2),colour = "black")+ # calls co-or for sig. line & draws geom_path(data=Diag, aes(x=x3, y=y3),colour = "black")+ geom_path(data=Diag, aes(x=x4, y=y4),colour = "black")+ geom_path(data=Diag, aes(x=x5, y=y5),colour = "black")+ geom_path(data=Diag, aes(x=x6, y=y6),colour = "black")+ geom_path(data=Diag, aes(x=x7, y=y7),colour = "black")
geom_jitter
.
Example.Data[5,] <- c(100, 'Bubble Pattern','Bubble Pattern' )
Example.Data$Variable = Relevel(Example.Data$Variable, ref = c("Diagonal Pattern", "Bubble Pattern","Horizontal Pattern","Mesh Pattern","Vertical Pattern"))
Example.Data$Bubbles <- 2
Example.Data$Points <- c(5, 10, 15, 20, 25)Example.Data$Points2 <- c(30, 35, 40, 45, 50)Example.Data$Points3 <- c(55, 60, 65, 70, 75)Example.Data$Points4 <- c(80, 85, 90, 95, 7)Example.Data$Points5 <- c(14, 21, 28, 35, 42)Example.Data$Points6 <- c(49, 56, 63, 71, 78)Example.Data$Points7 <- c(84, 91, 98, 6, 12)
geom_jitter
+geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points, size=Points), alpha=.5)+ geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points2, size=Points), alpha=.5)+ geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points, size=Points), alpha=.5)+ geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points2, size=Points), alpha=.5)+ geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points3, size=Points), alpha=.5)+ geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points4, size=Points), alpha=.5)+ geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points, size=Points), alpha=.5)+ geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points2, size=Points), alpha=.5)+ geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points, size=Points), alpha=.5)+ geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points2, size=Points), alpha=.5)+ geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points3, size=Points), alpha=.5)+ geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points4, size=Points), alpha=.5)+ geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points2, size=Points), alpha=.5)+ geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points5, size=Points), alpha=.5)+ geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points5, size=Points), alpha=.5)+ geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points6, size=Points), alpha=.5)+ geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points6, size=Points), alpha=.5)+ geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points7, size=Points), alpha=.5)+ geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points7, size=Points), alpha=.5)+ geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points, size=Points), alpha=.5)+ geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points2, size=Points), alpha=.5)+ geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points, size=Points), alpha=.5)+ geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points2, size=Points), alpha=.5)+ geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points3, size=Points), alpha=.5)+ geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points4, size=Points), alpha=.5)+ geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points, size=Points), alpha=.5)+ geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points2, size=Points), alpha=.5)+ geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points, size=Points), alpha=.5)+ geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points2, size=Points), alpha=.5)+ geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points3, size=Points), alpha=.5)+ geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points4, size=Points), alpha=.5)+ geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points2, size=Points), alpha=.5)+ geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points5, size=Points), alpha=.5)+ geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points5, size=Points), alpha=.5)+ geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points6, size=Points), alpha=.5)+ geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points6, size=Points), alpha=.5)+ geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points7, size=Points), alpha=.5)+ geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points7, size=Points), alpha=.5)
- 3 回答
- 0 关注
- 2361 浏览
添加回答
举报