From 5e331ad0cac32960aabbc1cad19f971b9efc6778 Mon Sep 17 00:00:00 2001
From: Shreesh2803 <spandey2_be22@thapar.edu>
Date: Mon, 23 Dec 2024 12:54:37 +0530
Subject: [PATCH] Renamed plot files to .R in the figure directory

---
 figure/plot1.R |  6 ++++++
 figure/plot2.R |  6 ++++++
 figure/plot3.R | 10 ++++++++++
 figure/plot4.R | 24 ++++++++++++++++++++++++
 4 files changed, 46 insertions(+)
 create mode 100644 figure/plot1.R
 create mode 100644 figure/plot2.R
 create mode 100644 figure/plot3.R
 create mode 100644 figure/plot4.R

diff --git a/figure/plot1.R b/figure/plot1.R
new file mode 100644
index 00000000000..769afeeb07e
--- /dev/null
+++ b/figure/plot1.R
@@ -0,0 +1,6 @@
+# plot1.R
+png("plot1.png", width = 480, height = 480)
+hist(data$Global_active_power, col = "red", 
+     main = "Global Active Power", 
+     xlab = "Global Active Power (kilowatts)")
+dev.off()
diff --git a/figure/plot2.R b/figure/plot2.R
new file mode 100644
index 00000000000..ffe00616cf2
--- /dev/null
+++ b/figure/plot2.R
@@ -0,0 +1,6 @@
+# plot2.R
+png("plot2.png", width = 480, height = 480)
+plot(data$DateTime, data$Global_active_power, type = "l", 
+     xlab = "", 
+     ylab = "Global Active Power (kilowatts)")
+dev.off()
diff --git a/figure/plot3.R b/figure/plot3.R
new file mode 100644
index 00000000000..d8732016418
--- /dev/null
+++ b/figure/plot3.R
@@ -0,0 +1,10 @@
+# plot3.R
+png("plot3.png", width = 480, height = 480)
+plot(data$DateTime, data$Sub_metering_1, type = "l", 
+     xlab = "", 
+     ylab = "Energy Sub Metering")
+lines(data$DateTime, data$Sub_metering_2, col = "red")
+lines(data$DateTime, data$Sub_metering_3, col = "blue")
+legend("topright", legend = c("Sub_metering_1", "Sub_metering_2", "Sub_metering_3"), 
+       col = c("black", "red", "blue"), lty = 1)
+dev.off()
diff --git a/figure/plot4.R b/figure/plot4.R
new file mode 100644
index 00000000000..4535f318509
--- /dev/null
+++ b/figure/plot4.R
@@ -0,0 +1,24 @@
+# plot4.R
+png("plot4.png", width = 480, height = 480)
+par(mfrow = c(2, 2))
+# Top-left
+plot(data$DateTime, data$Global_active_power, type = "l", 
+     xlab = "", 
+     ylab = "Global Active Power")
+# Top-right
+plot(data$DateTime, data$Voltage, type = "l", 
+     xlab = "datetime", 
+     ylab = "Voltage")
+# Bottom-left
+plot(data$DateTime, data$Sub_metering_1, type = "l", 
+     xlab = "", 
+     ylab = "Energy Sub Metering")
+lines(data$DateTime, data$Sub_metering_2, col = "red")
+lines(data$DateTime, data$Sub_metering_3, col = "blue")
+legend("topright", legend = c("Sub_metering_1", "Sub_metering_2", "Sub_metering_3"), 
+       col = c("black", "red", "blue"), lty = 1, bty = "n")
+# Bottom-right
+plot(data$DateTime, data$Global_reactive_power, type = "l", 
+     xlab = "datetime", 
+     ylab = "Global Reactive Power")
+dev.off()