Irises and Squids

Author

K M

Iris Plots

Reading in CSV file and creating a Scatterplot to show the Length and Width of 150 Iris Petals.

iris<-read.csv("~/Desktop/GEOG 5680/Data/iris.csv")
plot(iris$Petal.Length, iris$Petal.Width,
     xlab = "petal length (cm)", 
     ylab = "petal width (cm)", 
     main = "Scatterplot of Iris Petal Length and Width",
     pch = 20)

Creating a Scatterplot to show the Length and Width of 50 Setosa Iris Petals.

plot(Petal.Width~Petal.Length, data = iris, subset = c(Species == "setosa"),
     xlab = "petal length (cm)", 
     ylab = "petal width (cm)", 
     main = "Scatterplot of Iris Setosa Petal Length and Width",
     xlim = c(1,2), ylim = c(0,1),
     pch = 20)

Creating a Scatterplot to show the Length and Width of 150 Iris Petals, with each symbol representing a specific subset of Irises. The plot also includes a legend, indicating which symbol represents what species.

plot(Petal.Width~Petal.Length, data = iris,
     xlab = "petal length (cm)", 
     ylab = "petal width (cm)", 
     main = "Scatterplot of Iris Petal Length and Width",
     xlim = c(1,7), ylim = c(0,3),
     pch = Code)
legend("topleft",
       legend = c("Setosa", "Versicolor", "Virginica"),
       pch    = c(1,2,3))

Creating a new column in the dataset and creating vectors from that column to indicate what color each species will be graphed as.

iris$Colors = iris$Code
iris$Colors [iris$Code == 1] = "skyblue"
iris$Colors [iris$Code == 2] = "lavender"
iris$Colors [iris$Code == 3] = "pink"

Creating a Scatterplot to show the Length and Width of 150 Iris Petals, with each color representing a specific subset of Irises. The plot also includes a legend, indicating which color represents what species (as previously coded).

plot(Petal.Width~Petal.Length, data = iris,
     xlab = "petal length (cm)", 
     ylab = "petal width (cm)", 
     main = "Scatterplot of Iris Petal Length and Width",
     xlim = c(1,7), ylim = c(0,3),
     pch = 20, col = Colors)
legend("topleft",
       legend = c("Setosa", "Versicolor", "Virginica"),
       pch    = 20,
       col    = c("skyblue", "lavender", "pink"))

Creating a Scatterplot to show the Length and Width of 150 Iris Petals, with each color representing a specific subset of Irises. Each point is scaled by its’ sepal width (divided by 1.5 to scale each circle appropriately), with larger circles representing a higher sepal width.

plot(Petal.Width~Petal.Length, data = iris,
     xlab = "petal length (cm)", 
     ylab = "petal width (cm)", 
     main = "Scatterplot of Iris Petal Length and Width",
     xlim = c(1,7), ylim = c(0,3),
     pch = 21, cex = Sepal.Width/1.5,
     col = Colors)
legend("topleft",
       legend = c("Setosa", "Versicolor", "Virginica"),
       pch    = 21,
       col    = c("skyblue", "lavender", "pink"))     

Creating a Scatterplot to show the Length and Width of 150 Iris Petals, with each color representing a specific subset of Irises, and a line of best fit. The line of best fit represents the relationship between petal length and petal width.

scatter.smooth(iris$Petal.Length, iris$Petal.Width,
     xlab = "petal length (cm)", 
     ylab = "petal width (cm)", 
     main = "Scatterplot of Iris Petal Length and Width",
     xlim = c(1,7), ylim = c(0,3),
     pch = 20, col = iris$Colors,
     span = 1)

Squid Plots

Reading in CSV file and creating a histogram of Squid GSI.

squid<-read.csv("~/Desktop/GEOG 5680/Data/squid.csv")

hist(squid$GSI,
     xlab = "Gonadosomatic Index",
     main = "Histogram of Gonadosomatic Index of Squids (GSI)",
     col = "lightyellow")

First, creating a vector that separates the squid data by sex. Then, creating two histograms of Squid GSI: the first for male squids, and the second for female squids.

squid$Sex <- factor(squid$Sex, levels = c(1, 2), labels = c("Male", "Female"))
par(mfrow=c(2,1))
hist(squid$GSI[squid$Sex == "Male"],
     xlab = "Gonadosomatic Index",
     main = "Histogram of Gonadosomatic Index of Male Squids (GSI)",
     col = "steelblue")
hist(squid$GSI[squid$Sex == "Female"],
     xlab = "Gonadosomatic Index",
     main = "Histogram of Gonadosomatic Index of Female Squids (GSI)",
     col = "salmon")

par(mfrow=c(1,1))

Creating a vector of logged GSI values (scaling GSI values to better show the difference between sexes). Then creating a boxplot of the scaled GSI values by sex.

squid$GSI.Log <- log(squid$GSI)
boxplot(GSI.Log~Sex, data = squid,
        ylab = "GSI Logged", 
        main = "Box Plot of Gonadosomatic Index of Squids by Sex",
        col = c("steelblue","salmon"))

Creating a boxplot of scaled GSI values by location.

boxplot(GSI.Log~Location, data = squid,
        ylab = "GSI Logged", 
        main = "Box Plot of Gonadosomatic Index of Squids by Location",
        col = c("darkgreen","darkblue","beige","chocolate"))

THANK YOU