Module 11: Tufte Visuals
Module 11: Tufte Visuals
##Module 11: Tufts Visualizations
##install.packages(c("CarletonStats", "devtools", "epanetReader", "fmsb", "ggplot2", "ggthemes","latticeExtra", "MASS", "PerformanceAnalytics", "psych", "plyr"))
##nstall.packages(c("prettyR", "plotrix","proto", "RCurl", "reshape", "reshape2"))
library(CarletonStats)
library(devtools)
library(epanetReader)
library(fmsb)
library(ggplot2)
library(ggthemes)
library(latticeExtra)
library(MASS)
library(PerformanceAnalytics)
library(psych)
library(plyr)
library(prettyR)
library(plotrix)
library(proto)
library(RCurl)
library(reshape)
library(reshape2)
#Example R Script 1
library(devtools)
source_url("https://raw.githubusercontent.com/sjmurdoch/fancyaxis/master/fancyaxis.R")
x <- faithful$waiting
y <- faithful$eruptions
plot(x, y, main="", axes=FALSE, pch=16, cex=0.8,
xlab="Time till next eruption (min)", ylab="Duration (sec)",
xlim=c(min(x)/1.1, max(x)), ylim=c(min(y)/1.5, max(y)))
axis(1, tick=F)
axis(2, tick=F, las=2)
axisstripchart(faithful$waiting, 1)
axisstripchart(faithful$eruptions, 2)
lines(predict(lm(y~x)),col='green')
#I want to add a trendline to see what the linear trend is ^^
#Example R Script 2
#library(ggplot2)
#library(ggthemes)
data(mtcars)
acoriginal <- ggplot(mtcars, aes(wt, mpg)) + geom_point() + geom_rug() + theme_tufte(ticks=F) +
xlab("Car weight (lb/1000)") + ylab("Miles per gallon of fuel") +
theme(axis.title.x = element_text(vjust=-0.5), axis.title.y = element_text(vjust=1))
print(acoriginal)
#I will create clean variable subs for the column names to be renamed in the visual and then reintroduce them and some additional aesthetics
Horsepower <- mtcars$hp
Cylinders <- factor(mtcars$cyl)
#time to reload
ac <- ggplot(mtcars, aes(wt, mpg)) +
geom_point(aes(size = Horsepower, color = Cylinders)) +
geom_rug() +
theme_tufte(ticks=F) +
xlab("Car weight (lb/1000)") +
ylab("Miles per gallon of fuel") +
theme(
axis.title.x = element_text(vjust=-0.5),
axis.title.y = element_text(vjust=1))
print(ac)
#Lets compare
print(acoriginal)
print(ac)
##I decided to add some bells and whistles to my rendition of what was shown on the page provided for us. I was able tor recreate several but I picked these two because I found it easier to manipulate
##In short, some visual aspects are nice to have even in the wind of desired simplicity. Detail and Creativity are industry standards. That is with all things
#In knowing this, I wanted to have some fun messing around with the visuals.
Comments
Post a Comment