# Appelle des librairies nécessaires à la représentation graphique de la France
library('rgdal')
library('plotrix')
library('classInt')

# Appel du fichier qui contient le contour des communes
Communes <- readOGR(dsn = 'COMMUNE',layer = 'COMMUNE')
Communes <- merge(Communes,Tour1,by.x = 'INSEE_COM',by.y = 'CODE_INSEE')

# Appel du fichier qui contient les frontières françaises et les frontières régionales
Frontieres <- readOGR(dsn="COMMUNE",  layer="LIMITE_COMMUNE")
Frontieres <- Frontieres[Frontieres@data$NATURE %in% c('Frontière internationale','Limite côtière'),]

# Découpage en couleur par rapport aux taux d'abstention
col <- findColours(classIntervals(
  Communes$TX_ABSTENTION, 100, style="quantile"),
  smoothColors('#EFEBD2',98,"orange"))

leg <- findColours(classIntervals(
  round(Communes$TX_ABSTENTION,0), 6, style="quantile"),
  smoothColors("#EFEBD2",2,"orange"),
  under="moins de", over="plus de", between="–",
  cutlabels=FALSE)

# Affichage de la carte avec le taux d'abstention par communes
dev.new()
plot(Frontieres, col="#FFFFFF")
plot(Frontieres, col="#D8D6D4", lwd=6, add=TRUE)
plot(Communes,   col=col, border=col, lwd=0.1, add=TRUE)
plot(Frontieres, col="#666666", lwd=1, add=TRUE)
legend('topleft',fill=attr(leg, "palette"),
       legend=gsub("\\.", ",", names(attr(leg,"table"))),
       title = "Taux d'abstention par communes:",bty = 'n')