borders <- read.csv("data/texas.csv")
View(borders)
tx <- qplot(long, lat, data = "borders", geom = "polygon", fill = bin, aes = group)
tx
library(ggplot2)
tx <- qplot(long, lat, data = "borders", geom = "polygon", fill = bin, aes = group)
tx
tx <- qplot(long, lat, data = borders, geom = "polygon", fill = bin, aes = group)
tx
tx <- qplot(long, lat, data = borders, geom = "polygon", fill = bin, group = group)
tx
tx + ggtitle("Population of Texas Counties)
")
ggtitle("Population of Texas Counties")
class(ggtitle("Population of Texas Counties"))
tx + theme_grey()
ggsave("tx1.png", width = 6, height = 6)
tx + theme_bw()
ggsave("tx2.png", width = 6, height = 6)
tx + coord_cartesian()
tx + coord_map()
tx + coord_map("lambert")
tx + coord_map("mercator")
tx + coord_map("polar")
tx + coord_map("azequalarea")
?coord_map
tx + coord_map("perspective")
tx + coord_map("mercator")
ggsave("tx3.png", width = 6, height = 6)
tx +
ggtitle("Population of Texas Counties") +
theme_bw() +
coord_map("mercator")
ggsave("tx4.png", width = 8, height = 6)
tx + coord_cartesian(xlim = c(-96, -94), ylim = c(29.5, 30.5))
tx + coord_cartesian(xlim = c(-96, -94), ylim = c(29.25, 30.25))
ggsave("tx5.png", width = 6, height = 6)
library(ggplot2)
p <- qplot(displ, hwy, data = mpg, color = class) +
()
p <- qplot(displ, hwy, data = mpg, color = class)
p
p + scale_color_discrete(limits = c("compact", "subcompact"))
p + scale_x_continuous(limits = c(3,6))
p + scale_y_continuous(name = "Highway mpg")
ggsave("1.png", width = 8, height = 6_
ggsave("1.png", width = 8, height = 6)
p + scale_y_continuous(breaks = c(15, 20, 25, 30, 35, 40))
ggsave("2.png", width = 8, height = 6)
p + scale_y_continuous(breaks = c(15, 20, 25, 30, 35, 40),
labels = c("a", "b", "c", "d", "e", "f"))
ggsave("3.png", width = 8, height = 6)
p + scale_y_continuous(limits = c(30, 35))
p + scale_y_continuous(limits = c(21, 39))
p + scale_y_continuous(limits = c(25, 35))
ggsave("4.png", width = 8, height = 6)
show_col(brewer_pal(palette = "YlOrRd")(9))
library(RColorBrewer)
show_col(brewer_pal(palette = "YlOrRd")(9))
library(scales)
show_col(brewer_pal(palette = "YlOrRd")(9))
library(ggplot2)
ggplot() +
geom_point(
aes(x = carat, y = price),
data = diamonds) +
geom_smooth(
aes(x = carat, y = price,
color = cut),
data = diamonds)
qplot(displ, cty, colour = drv, shape = fl, data = mpg)
ggplot(mpg, aes(displ, cty)) +
geom_point() +
geom_smooth(aes(color = class))
ggplot(mpg, aes(displ, cty)) +
geom_point() +
geom_smooth(aes(color = drv))
ggplot(mpg, aes(displ, cty)) +
geom_point(aes(color = drv)) +
geom_smooth()
ggsave("ex1.png", width = 6, height = 6)
ggplot(mpg, aes(class, hwy)) +
geom_boxplot() +
geom_point(aes(color = class), position = "jitter")
ggplot(mpg, aes(class, hwy)) +
geom_point(aes(color = class), position = "jitter") +
geom_boxplot()
ggplot(mpg, aes(class, hwy)) +
geom_point(aes(color = class), position = "jitter") +
geom_boxplot(aes(color = class))
ggplot(mpg, aes(class, hwy)) +
geom_point(position = "jitter") +
geom_boxplot(aes(color = class))
ggsave("ex2.png", width = 6, height = 6)
qplot(carat, price, data = diamonds, geom = "smooth")
ggsave("smooth1.png", width = 8, height = 6)
qplot(carat, price, data = diamonds, geom = "smooth", group = cut)
ggsave("smooth3.png", width = 8, height = 6)
qplot(carat, price, data = diamonds, geom = "smooth", color = cut, se = FALSE)
ggsave("smooth4.png", width = 8, height = 6)
qplot(carat, price, data = diamonds, geom = "smooth", color = cut, se = FALSE, method = lm)
ggsave("smooth5.png", width = 8, height = 6)
ggplot(mpg, aes(displ, cty)) +
geom_point(aes(color = drv)) +
geom_smooth()
ggsave("ex1.png", width = 6, height = 4)
ggplot(mpg, aes(class, hwy)) +
geom_point(position = "jitter") +
geom_boxplot(aes(color = class))
ggsave("ex2.png", width = 6, height = 4)
qplot(class, hwy, data = mpg, position = "jitter", color = class)
