Hello,

I have data of Body length and Body weight of 8 boys and 7 girls.

I want to draw the plot of Body length (for X) and Body weight (for Y)
based on sex.
Then the two plots want to be overlapped for comparison.

I used the code below but found the unit length of X axis of boy and
girl plot are not the same.
For instance, the length between 0 and 1 of boy plot is larger than
that in girl plot.
The same thing happened to Y axis as well.
(In other words, though axap and yaxp were set to be the same, the
display were not the same.)

Please kindly advise correction of the code.
Thank you.

Elaine

# plot code
    boy<-read.csv("H:/boy_data.csv",header=T)
    girl<-read.csv("H:/girl_data.csv",header=T)
par(mai=c(1.03,1.03,0.4,0.4))

    plot(boy$body_length, boy$body_weight,
    xlab=" body_length (cm)",
    ylab=" body_weight  ( kg )",
    xaxp=c(0,200,4),
    yaxp=c(0,100,4),
    type="p",
    pch=1,lwd=1.0,
    cex.lab=1.4, cex.axis=1.2,
    font.axis=2,
    cex=1.5,
    las=1,
    bty="l",col="firebrick3")

    boyline<-lm(body_weight ~ body_length, boy)
    summary(boyline)
    abline(boyline,col="firebrick3",lwd=2)

    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # graph
    par(mai=c(1.03,1.03,0.4,0.4))

    par(new=T)

    plot(girl$body_length, girl$body_weight,
    xlab=" body_length (cm)",
    ylab=" body_weight  ( kg )",
    xaxp=c(0,200,4),
    yaxp=c(0,100,4),
    type="p",
    pch=1,lwd=1.0,
    cex.lab=1.4, cex.axis=1.2,
    font.axis=2,
    cex=1.5,
    las=1,
    bty="l",col="saddlebrown")


    girlline<-lm(body_weight~ body_length, girl)
    summary(girlline)
    abline(girlline,col="saddlebrown",lwd=2)

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to