Coder Social home page Coder Social logo

exdata_plotting1's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

exdata_plotting1's Issues

plot2.R

hpc <- read.csv("household_power_consumption.txt", sep=";",
na.strings="?",stringsAsFactors=FALSE)
hpc2<-subset(hpc,hpc$Date==c("1/2/2007","2/2/2007"))
hpc2$Timestamp = strptime(paste(hpc2$Date, hpc2$Time),
format = "%d/%m/%Y %H:%M:%S")
Sys.setlocale("LC_TIME", "C")
with(hpc2,plot(Timestamp,Global_active_power, type ="l", ylab = "Global active power (kilowatts)"
,xlab=" ",ylim=c(0,6)))
dev.copy(png,file="plot2.png",width=480,height=480)
dev.off()

plot4.R

hpc <- read.csv("household_power_consumption.txt", sep=";",
na.strings="?",stringsAsFactors=FALSE)
hpc2<-subset(hpc,hpc$Date==c("1/2/2007","2/2/2007"))
hpc2$Timestamp = strptime(paste(hpc2$Date, hpc2$Time),
format = "%d/%m/%Y %H:%M:%S")
Sys.setlocale("LC_TIME", "C")
par(mfrow=c(2,2))
with(hpc2,plot(Timestamp,Global_active_power,type="l",ylim=c(0,6),xlab=" ",ylab="Global Active Power"))
with(hpc2,plot(Timestamp,Voltage,type="l",ylim=c(234,246),xlab="datetime",ylab="Voltage"))
with(hpc2,plot(Timestamp,Sub_metering_1,type="l",col="black", xlab=" ",ylab="Energy sub metering"))
points(hpc2$Timestamp,hpc2$Sub_metering_2,type="l",col="red")
points(hpc2$Timestamp,hpc2$Sub_metering_3,type="l",col="blue")
legend("topright",cex=0.3,lty=1:1,bty="n",col=c("black","red","blue"), legend=c("Sub_metering_1","Sub_metering_2","Sub_metering_3"))
with(hpc2,plot(Timestamp,Global_reactive_power,type="l",ylim=c(0.0,0.5),xlab="datetime",ylab="Global_reactive_power"))
dev.copy(png,file="plot4.png")
dev.off()

plot3.R

plot(Sub_metering_1, xlab=" ", ylab="Energy Sub Metering",
type="l", col="black")
lines(Sub_metering_2, col="red")
lines(Sub_metering_3, col="blue")
legend("topright", legend = c("Sub_metering_1","Sub_metering_2","Sub_metering_3"), col = c("black", "red", "blue"), lty = c(1,1,1))
dev.copy(png, file = "plot3.png", width=480,height=480) ## Copy plot to a PNG file
dev.off() ## close the PNG device

possible minor issue in the 4th plot?

For the 4th plot:
4th_plot

The y-label of the 4th subplot (Global Reactive Power vs datetime) has not been formatted yet. The prettier y-label should be like, 'Global Reactive Power'.

Is this a bug or intention by the author?

plot2.R

plot2 <- plot(Global_active_power, type ="l", ylab = "Global active power (kilowatts)", xlab = "") ## Create plot on screen device

dev.copy(png, file = "plot2.png") ## Copy plot to a PNG file
dev.off() ## close the PNG device

plots

plot1.R
plot1
data
+#plot 1
+PowerConsumption <- read.table("household_power_consumption.txt",sep=";",header=TRUE,stringsAsFactors=FALSE)
+head(PowerConsumption)
+dim(PowerConsumption)
+class(PowerConsumption)
+
+#Plot 1 - using data from the dates 02-01-2007 and 02-02-2007
+PowerConsumption$Date=strptime(PowerConsumption$Date, format="%d/%m/%Y")
+PowerConsumption$Global_active_power=as.numeric(PowerConsumption$Global_active_power)
+PowerConsumption$Global_intensity=as.numeric(PowerConsumption$Global_intensity)
+PowerConsumption$Global_reactive_power=as.numeric(PowerConsumption$Global_reactive_power)
+PowerConsumption$Sub_metering_1=as.numeric(PowerConsumption$Sub_metering_1)
+PowerConsumption$Sub_metering_2=as.numeric(PowerConsumption$Sub_metering_2)
+PowerConsumption$Sub_metering_3=as.numeric(PowerConsumption$Sub_metering_3)
+PowerConsumption$Voltage=as.numeric(PowerConsumption$Voltage)
+
+PowerConsumption=subset(PowerConsumption,PowerConsumption$Date>as.POSIXlt("2007-01-31") & PowerConsumption$Date<as.POSIXlt("2007-02-03"))
+
+png(file="plot1.png",width=480,height=480)
+hist(PowerConsumption$Global_active_power,col="red",main="Global Active Power",xlab="Global Active Power (kilowatts)")
+dev.off()

plot1.R

plot1 <- hist(Global_active_power, col ="red", main = paste("Global active power"), xlab = "Global active power (kilowatts)")
plot1 ## Create plot on screen device
dev.copy(png, file = "plot1.png") ## Copy plot to a PNG file
dev.off() ## close the PNG device

plot3.R

hpc <- read.csv("household_power_consumption.txt", sep=";",
na.strings="?",stringsAsFactors=FALSE)
hpc2<-subset(hpc,hpc$Date==c("1/2/2007","2/2/2007"))
hpc2$Timestamp = strptime(paste(hpc2$Date, hpc2$Time),
format = "%d/%m/%Y %H:%M:%S")
Sys.setlocale("LC_TIME", "C")
with(hpc2,plot(Timestamp,Sub_metering_1,type="l",col="black",
xlab=" ",ylab="Energy sub metering"))
points(hpc2$Timestamp,hpc2$Sub_metering_2,type="l",col="red")
points(hpc2$Timestamp,hpc2$Sub_metering_3,type="l",col="blue")
legend("topright",cex=0.6,lty=1:1,col=c("black","red","blue"),
legend=c("Sub_metering_1","Sub_metering_2","Sub_metering_3"))
dev.copy(png,file="plot3.png")
dev.off()

plot1.R

hpc <- read.csv("household_power_consumption.txt", sep=";", na.strings="?",
stringsAsFactors=FALSE)
hpc2 <- hpc[min(which(hpc$Date == "1/2/2007")):max(which(hpc$Date == "2/2/2007")),]
hist(hpc2$Global_active_power,main="Global Active Power",xlab="Global Active Power(kilowatts)",col="red",breaks=12,ylim=c(0,1200))
dev.copy(png,width=480,height=480,file="plot1.png")
dev.off()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.