Setosa sepals are bigger than petals in both length and width:
summary(subset(iris, Species == "setosa"))
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
Min. :4.300 Min. :2.300 Min. :1.000 Min. :0.100 setosa :50
1st Qu.:4.800 1st Qu.:3.200 1st Qu.:1.400 1st Qu.:0.200 versicolor: 0
Median :5.000 Median :3.400 Median :1.500 Median :0.200 virginica : 0
Mean :5.006 Mean :3.428 Mean :1.462 Mean :0.246
3rd Qu.:5.200 3rd Qu.:3.675 3rd Qu.:1.575 3rd Qu.:0.300
Max. :5.800 Max. :4.400 Max. :1.900 Max. :0.600
However, in the first example with iris in ?matplot, setosa petals (small red "s") appear
to be longer and wider than sepals (big blue "S"). The symbols for versicolor are also
swapped. (I'm using R 4.5.2.)
A possible fix is to change legend() to put "Sepals" before "Petals" for both
species. This ordering corresponds with the column indexing used in the example:
iS <- iris$Species == "setosa"
names(iris[iS,c(1,3)]) == c("Sepal.Length", "Petal.Length")
names(iris[iS,c(2,4)]) == c("Sepal.Width", "Petal.Width")
The original legend used bigger (uppercase) symbols for bigger flower parts. Whether or not this was intentional, it is
an intuitive choice. Such a congruence can be maintained by changing "sS" to "Ss" and
"vV" to "Vv" in all three pch assignments.
Here is a modified example with the proposed changes in legend and pch.
table(iris$Species) # is data.frame with 'Species' factor
iS <- iris$Species == "setosa"
iV <- iris$Species == "versicolor"
op <- par(bg = "bisque")
matplot(c(1, 8), c(0, 4.5), type = "n", xlab = "Length", ylab = "Width",
main = "Petal and Sepal Dimensions in Iris Blossoms")
matpoints(iris[iS,c(1,3)], iris[iS,c(2,4)], pch = "Ss", col = c(2,4))
matpoints(iris[iV,c(1,3)], iris[iV,c(2,4)], pch = "Vv", col = c(2,4))
legend(1, 4, c(" Setosa Sepals", " Setosa Petals",
"Versicolor Sepals", "Versicolor Petals"),
pch = "SsVv", col = rep(c(2,4), 2))
Regards,
Jeff Dick
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel