Skip to content

Commit

Permalink
Adds state secciones nyt maps
Browse files Browse the repository at this point in the history
  • Loading branch information
emagar committed Jul 11, 2018
1 parent 239826e commit cc456b2
Show file tree
Hide file tree
Showing 93 changed files with 94 additions and 28 deletions.
122 changes: 94 additions & 28 deletions code/plot2018pr.r
Original file line number Diff line number Diff line change
Expand Up @@ -926,8 +926,7 @@ summary(pr.se$camloneg[pr.se$camloneg<0])
summary(pr.se$cprineg[pr.se$cprineg<0])
summary(pr.se$cpanneg[pr.se$cpanneg<0])


edon <- 1
edon <- 31
edo <- edos[edon]

#################
Expand Down Expand Up @@ -972,10 +971,12 @@ ed.map <- tmp
plot(mu.map, lwd = .5, border = "gray")
axis(1); axis(2)

# amlo v pan
###################################
# amlo v pri secciones por estado #
###################################
library(graphics)
#png("/home/eric/Desktop/MXelsCalendGovt/elecReturns/graph/nytPlusPri.png", width = 20, height = 20, units = "cm", res = 196)
#pdf("/home/eric/Desktop/MXelsCalendGovt/elecReturns/graph/nytPlusPri.pdf", width = 10, height = 7)
#png(paste("/home/eric/Desktop/MXelsCalendGovt/elecReturns/graph/nytPlusPri-", edo, ".png", sep = ""), width = 20, height = 20, units = "cm", res = 196)
#pdf(paste("/home/eric/Desktop/MXelsCalendGovt/elecReturns/graph/nytPlusPri-", edo, ".pdf", sep = ""), width = 10, height = 7)
par(mar = c(0,0,0,0))
#plot(shave(mu.map, p = .95), lwd = .5, border = "gray")
plot(se.map, lwd = .25, border = "lightgray")
Expand All @@ -986,30 +987,95 @@ plot(ed.map, lwd = .5, lty = 3, border = "gray", add = TRUE)
# add arrows
# start-end of arrows
#cx <- 150000; cy <- cx/3
xlength <- (tmp.ranges[2] - tmp.ranges[1]) / 8
for (i in 1:nrow(se.map@data)){
# start-end of arrows
#i <- 1 # debug
cx <- xlength*se.map$camlopos; cy <- cx/3
arrows(coordinates(se.map)[,1], coordinates(se.map)[,2],
coordinates(se.map)[,1]-cx, coordinates(se.map)[,2]+cy,
length = .025, angle = 10,
col = brown, lwd = (.1+cx/xlength))
cx <- xlength*se.map$cpanpos; cy <- cx/3
arrows(coordinates(se.map)[,1], coordinates(se.map)[,2],
coordinates(se.map)[,1]+cx, coordinates(se.map)[,2]+cy,
length = .025, angle = 10,
col = colpan, lwd = (.1+cx/xlength))
}
xlength <- (tmp.ranges[2] - tmp.ranges[1]) / 10
#
# start-end of arrows
cx <- xlength*se.map$camlopos; cy <- cx/3
arrows(coordinates(se.map)[,1], coordinates(se.map)[,2],
coordinates(se.map)[,1]-cx, coordinates(se.map)[,2]+cy,
length = .025, angle = 10,
col = brown, lwd = (.1+cx/(xlength*.4)))
cx <- xlength*se.map$cpripos; cy <- cx/3
arrows(coordinates(se.map)[,1], coordinates(se.map)[,2],
coordinates(se.map)[,1]+cx, coordinates(se.map)[,2]+cy,
length = .025, angle = 10,
col = colpri, lwd = (.1+cx/(xlength*.4)))
# legend
#xl <- -11440000; yl <- 2555000
xl <- tmp.ranges[2]-(tmp.ranges[2]-tmp.ranges[1])*.1; yl <- tmp.ranges[4]-(tmp.ranges[4]-tmp.ranges[3])*.1
arrows(xl,yl,xl-xlength*.6,yl+xlength*.6/3,length = .025, angle = 10, col = brown, lwd = 2)
xl <- tmp.ranges[2] - (tmp.ranges[2] - tmp.ranges[1])*.20
yl <- tmp.ranges[4] - (tmp.ranges[4] - tmp.ranges[3])*.15
arrows(xl,yl,xl-xlength*.5,yl+xlength*.5/3,length = .025, angle = 10, col = brown, lwd = 2)
text(xl, yl, pos = 4, labels = "AMLO creció", cex = .75)
arrows(xl+310000,yl-150000,xl+310000+150000,yl-150000+50000,length = .025, angle = 10, col = colpan, lwd = .75)
text(xl+310000,yl-150000, pos = 2, labels = "Anaya creció", cex = .75)
text(xl+180000, yl+280000, labels = "Cambio desde", font = 2)
text(xl+180000, yl+180000, labels = "2012 en secciones", font = 2)
text(-13000000, 1550000, labels = "Preparado por Eric Magar con datos del INE (ericmagar.com)", col = "lightgray", pos = 4, cex = .65)
#dev.off()
#
xl <- tmp.ranges[2] - (tmp.ranges[2] - tmp.ranges[1])*.07
yl <- tmp.ranges[4] - (tmp.ranges[4] - tmp.ranges[3])*.18
arrows(xl,yl,xl+xlength*.5,yl+xlength*.5/3,length = .025, angle = 10, col = colpri, lwd = 2)
text(xl,yl, pos = 2, labels = "Meade creció", cex = .75)
#
xl <- tmp.ranges[2] - (tmp.ranges[2] - tmp.ranges[1])*.135
yl <- tmp.ranges[4] - (tmp.ranges[4] - tmp.ranges[3])*.07
text(xl, yl, labels = "Cambio desde", font = 2)
xl <- tmp.ranges[2] - (tmp.ranges[2] - tmp.ranges[1])*.135
yl <- tmp.ranges[4] - (tmp.ranges[4] - tmp.ranges[3])*.10
text(xl, yl, labels = "2012 en secciones", font = 2)
xl <- tmp.ranges[2] - (tmp.ranges[2] - tmp.ranges[1])*.9
yl <- tmp.ranges[4] - (tmp.ranges[4] - tmp.ranges[3])*.95
#
text(xl, yl, labels = "Preparado por Eric Magar con datos del INE (ericmagar.com)", col = "lightgray", pos = 4, cex = .65)
dev.off()


###################################
# amlo v pan secciones por estado #
###################################
library(graphics)
#png(paste("/home/eric/Desktop/MXelsCalendGovt/elecReturns/graph/nytPlusPan-", edo, ".png", sep = ""), width = 20, height = 20, units = "cm", res = 196)
#pdf(paste("/home/eric/Desktop/MXelsCalendGovt/elecReturns/graph/nytPlusPan-", edo, ".pdf", sep = ""), width = 10, height = 7)
par(mar = c(0,0,0,0))
#plot(shave(mu.map, p = .95), lwd = .5, border = "gray")
plot(se.map, lwd = .25, border = "lightgray")
tmp.ranges <- par("usr") # keep calculated xy ranges to compute arrow length
plot(mu.map, lwd = .5, border = "gray", add = TRUE)
plot(mu.map, lwd = .5, lty = 3, border = "white", add = TRUE)
plot(ed.map, lwd = .5, lty = 3, border = "gray", add = TRUE)
# add arrows
# start-end of arrows
#cx <- 150000; cy <- cx/3
xlength <- (tmp.ranges[2] - tmp.ranges[1]) / 10
#
# start-end of arrows
cx <- xlength*se.map$camlopos; cy <- cx/3
arrows(coordinates(se.map)[,1], coordinates(se.map)[,2],
coordinates(se.map)[,1]-cx, coordinates(se.map)[,2]+cy,
length = .025, angle = 10,
col = brown, lwd = (.1+cx/(xlength*.4)))
cx <- xlength*se.map$cpanpos; cy <- cx/3
arrows(coordinates(se.map)[,1], coordinates(se.map)[,2],
coordinates(se.map)[,1]+cx, coordinates(se.map)[,2]+cy,
length = .025, angle = 10,
col = colpan, lwd = (.1+cx/(xlength*.4)))
# legend
#xl <- -11440000; yl <- 2555000
xl <- tmp.ranges[2] - (tmp.ranges[2] - tmp.ranges[1])*.2
yl <- tmp.ranges[4] - (tmp.ranges[4] - tmp.ranges[3])*.15
arrows(xl,yl,xl-xlength*.5,yl+xlength*.5/3,length = .025, angle = 10, col = brown, lwd = 2)
text(xl, yl, pos = 4, labels = "AMLO creció", cex = .75)
#
xl <- tmp.ranges[2] - (tmp.ranges[2] - tmp.ranges[1])*.07
yl <- tmp.ranges[4] - (tmp.ranges[4] - tmp.ranges[3])*.18
arrows(xl,yl,xl+xlength*.5,yl+xlength*.5/3,length = .025, angle = 10, col = colpan, lwd = 2)
#arrows(xl+310000,yl-150000,xl+310000+150000,yl-150000+50000,length = .025, angle = 10, col = colpan, lwd = .75)
text(xl,yl, pos = 2, labels = "Anaya creció", cex = .75)
#
xl <- tmp.ranges[2] - (tmp.ranges[2] - tmp.ranges[1])*.135
yl <- tmp.ranges[4] - (tmp.ranges[4] - tmp.ranges[3])*.07
text(xl, yl, labels = "Cambio desde", font = 2)
xl <- tmp.ranges[2] - (tmp.ranges[2] - tmp.ranges[1])*.135
yl <- tmp.ranges[4] - (tmp.ranges[4] - tmp.ranges[3])*.10
text(xl, yl, labels = "2012 en secciones", font = 2)
xl <- tmp.ranges[2] - (tmp.ranges[2] - tmp.ranges[1])*.9
yl <- tmp.ranges[4] - (tmp.ranges[4] - tmp.ranges[3])*.95
text(xl, yl, labels = "Preparado por Eric Magar con datos del INE (ericmagar.com)", col = "lightgray", pos = 4, cex = .65)
dev.off()


Binary file added graph/nytPlusPan-ags.pdf
Binary file not shown.
Binary file added graph/nytPlusPan-ags.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added graph/nytPlusPan-bc.pdf
Binary file not shown.
Binary file added graph/nytPlusPan-bc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added graph/nytPlusPan-bcs.pdf
Binary file not shown.
Binary file added graph/nytPlusPan-bcs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added graph/nytPlusPan-coa.pdf
Binary file not shown.
Binary file added graph/nytPlusPan-coa.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added graph/nytPlusPan-cps.pdf
Binary file not shown.
Binary file added graph/nytPlusPan-cps.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added graph/nytPlusPan-cua.pdf
Binary file not shown.
Binary file added graph/nytPlusPan-cua.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added graph/nytPlusPan-df.pdf
Binary file not shown.
Binary file added graph/nytPlusPan-df.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added graph/nytPlusPan-dgo.pdf
Binary file not shown.
Binary file added graph/nytPlusPan-dgo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added graph/nytPlusPan-gua.pdf
Binary file not shown.
Binary file added graph/nytPlusPan-gua.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added graph/nytPlusPan-gue.pdf
Binary file not shown.
Binary file added graph/nytPlusPan-gue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added graph/nytPlusPan-hgo.pdf
Binary file not shown.
Binary file added graph/nytPlusPan-hgo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added graph/nytPlusPan-jal.pdf
Binary file not shown.
Binary file added graph/nytPlusPan-jal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added graph/nytPlusPan-nay.pdf
Binary file not shown.
Binary file added graph/nytPlusPan-nay.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added graph/nytPlusPan-nl.pdf
Binary file not shown.
Binary file added graph/nytPlusPan-nl.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added graph/nytPlusPan-oax.pdf
Binary file not shown.
Binary file added graph/nytPlusPan-oax.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added graph/nytPlusPan-san.pdf
Binary file not shown.
Binary file added graph/nytPlusPan-san.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added graph/nytPlusPan-sin.pdf
Binary file not shown.
Binary file added graph/nytPlusPan-sin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added graph/nytPlusPan-son.pdf
Binary file not shown.
Binary file added graph/nytPlusPan-son.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added graph/nytPlusPan-tam.pdf
Binary file not shown.
Binary file added graph/nytPlusPan-tam.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added graph/nytPlusPan-tla.pdf
Binary file not shown.
Binary file added graph/nytPlusPan-tla.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added graph/nytPlusPan-ver.pdf
Binary file not shown.
Binary file added graph/nytPlusPan-ver.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added graph/nytPlusPan-yuc.pdf
Binary file not shown.
Binary file added graph/nytPlusPan-yuc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added graph/nytPlusPan-zac.pdf
Binary file not shown.
Binary file added graph/nytPlusPan-zac.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added graph/nytPlusPri-ags.pdf
Binary file not shown.
Binary file added graph/nytPlusPri-ags.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added graph/nytPlusPri-bc.pdf
Binary file not shown.
Binary file added graph/nytPlusPri-bc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added graph/nytPlusPri-bcs.pdf
Binary file not shown.
Binary file added graph/nytPlusPri-bcs.png
Binary file added graph/nytPlusPri-coa.pdf
Binary file not shown.
Binary file added graph/nytPlusPri-coa.png
Binary file added graph/nytPlusPri-cps.pdf
Binary file not shown.
Binary file added graph/nytPlusPri-cps.png
Binary file added graph/nytPlusPri-cua.pdf
Binary file not shown.
Binary file added graph/nytPlusPri-cua.png
Binary file added graph/nytPlusPri-df.pdf
Binary file not shown.
Binary file added graph/nytPlusPri-df.png
Binary file added graph/nytPlusPri-dgo.pdf
Binary file not shown.
Binary file added graph/nytPlusPri-dgo.png
Binary file added graph/nytPlusPri-gua.pdf
Binary file not shown.
Binary file added graph/nytPlusPri-gua.png
Binary file added graph/nytPlusPri-gue.pdf
Binary file not shown.
Binary file added graph/nytPlusPri-gue.png
Binary file added graph/nytPlusPri-hgo.pdf
Binary file not shown.
Binary file added graph/nytPlusPri-hgo.png
Binary file added graph/nytPlusPri-jal.pdf
Binary file not shown.
Binary file added graph/nytPlusPri-jal.png
Binary file added graph/nytPlusPri-nay.pdf
Binary file not shown.
Binary file added graph/nytPlusPri-nay.png
Binary file added graph/nytPlusPri-nl.pdf
Binary file not shown.
Binary file added graph/nytPlusPri-nl.png
Binary file added graph/nytPlusPri-oax.pdf
Binary file not shown.
Binary file added graph/nytPlusPri-oax.png
Binary file added graph/nytPlusPri-san.pdf
Binary file not shown.
Binary file added graph/nytPlusPri-san.png
Binary file added graph/nytPlusPri-sin.pdf
Binary file not shown.
Binary file added graph/nytPlusPri-sin.png
Binary file added graph/nytPlusPri-son.pdf
Binary file not shown.
Binary file added graph/nytPlusPri-son.png
Binary file added graph/nytPlusPri-tam.pdf
Binary file not shown.
Binary file added graph/nytPlusPri-tam.png
Binary file added graph/nytPlusPri-tla.pdf
Binary file not shown.
Binary file added graph/nytPlusPri-tla.png
Binary file added graph/nytPlusPri-ver.pdf
Binary file not shown.
Binary file added graph/nytPlusPri-ver.png
Binary file added graph/nytPlusPri-yuc.pdf
Binary file not shown.
Binary file added graph/nytPlusPri-yuc.png
Binary file added graph/nytPlusPri-zac.pdf
Binary file not shown.
Binary file added graph/nytPlusPri-zac.png

0 comments on commit cc456b2

Please sign in to comment.