######################################################### #Nicol, A. A. M., & Pexman, P. M. (2003). #Introduction. In Displaying your findings: A practical guide for creating figures, posters, and presentations (pp.1-12). #Washington, DC: American PsychologicalAssociation ######################################################### setwd("C:/data/Figure") #適当に作業フォルダを変更 #------------------------------# # Figure 1.1 #------------------------------# ##(a) データの作成 Attitude <- matrix(c( 3.5, 3.3, 3.0, 2.8, 4.2, 2.9, 4.4, 3.2, 5.2, 3.4 ),ncol=2,byrow=T) dat1 <- Attitude rownames(dat1) <- c("9:00 a.m.","11:00 a.m.","1:00 p.m.","3:00 p.m.","5:00 p.m.") colnames(dat1) <- c("Monday", "Friday") ##(b) 図を描画 matplot(dat1, pch=c(15,22), #プロット点のタイプ col="black", ylim = c(0,6), #y軸の幅 xlab = "Time of Day", #x軸の名前 ylab = "Work Attitude", #y軸の名前 xaxt = "n" ) matlines(dat1,lty=1, col="black") legend(x=4,y=1, legend=colnames(dat1), pch=c(15,22), lwd=1,col="black") axis(side=1, at=1:5,labels=rownames(dat1)) ##(c) 図を出力 savePlot(filename="Fig1.1",type="wmf") graphics.off() #------------------------------# # Figure 1.3 #------------------------------# windows(width=4, height=7) par(mfrow=c(2,1), mar=c(5,5,0,1),xpd=2) ##(a) データの作成 Cor1 <- c(.7,.55,.38) Cor2 <- c(.62,.55,.35) Situation <- c("Identical", "Franternal","Siblings") ##(b) 図を描画(上) barplot(Cor1, ylim=c(0,1), ylab="Mean Correlation", xlab="Situation", names.arg=Situation, axis.lty=1, col="black",yaxt="n") ylab1 <- substr(formatC(seq(0,.9,by=.1), format="f",digits=1),start=2,stop=3) axis(side=2, at=seq(0,.9,by=.1),labels=ylab1,las=1) text(x=-.7, y=.9, label="A", cex=2) ##(c) 図を描画(下) barplot(Cor2, ylim=c(0,1), ylab="Mean Correlation", xlab="Situation", names.arg=Situation, axis.lty=1, col="black",yaxt="n") ylab1 <- substr(formatC(seq(0,.9,by=.1), format="f",digits=1),start=2,stop=3) axis(side=2, at=seq(0,.9,by=.1),labels=ylab1,las=1) text(x=-.7, y=.9, label="B", cex=2) ##(d) 図を出力 savePlot(filename="Fig1.3",type="wmf") graphics.off()