Fichier:Opinion polling for the 2022 Hungarian parliamentary election by parties.svg

De testwiki
Aller à la navigation Aller à la recherche
Fichier d’origine (Fichier SVG, nominalement de 1 620 × 900 pixels, taille : 327 kio)

Ce fichier provient de Wikimedia Commons et peut être utilisé par d'autres projets. Sa description sur sa page de description est affichée ci-dessous.

Description

Description
English: Opinion polling for the 2022 Hungarian parliamentary election using local regressions (LOESS)
Code template: https://gitlab.com/gbuvn1/opinion-polling-graph
ggplot.R
Sys.setlocale("LC_TIME", "English")
library(ggplot2)
library(anytime)
library(tidyverse)
library(svglite)

polls <- read.table("CAT.csv", header=T, sep=",", fileEncoding="UTF-8", stringsAsFactor=F)
polls$polldate <- as.Date(anydate(polls$polldate))

spansize <- 0.1         # general smoothing parameter for trend line
startdate <- '2018-04-08'   # date of previous election
enddate <- '2022-04-08'     # (latest) date of next election

# retrieve party names from CSV
party1 <- colnames(polls)[2]
party2 <- colnames(polls)[3]
party3 <- colnames(polls)[4]
party4 <- colnames(polls)[5]
party5 <- colnames(polls)[6]
party6 <- colnames(polls)[7]
party7 <- colnames(polls)[8]
party8 <- colnames(polls)[9]
party9 <- colnames(polls)[10]

# define party colors (taken from https://en.wikipedia.org/wiki/Category:Germany_political_party_colour_templates)
col1 <- '#FF6A00'
col2 <- '#008371'
col3 <- '#CC0000'
col4 <- '#3CB34D'
col5 <- '#36CA8B'
col6 <- '#0067AA'
col7 <- '#8E6FCE'
col8 <- '#808080'
col9 <- '#568203'

transp <-'55'       # transparency level of points

graph <- ggplot(polls)+
  geom_vline(xintercept = as.Date(startdate), color='#aaaaaabb')+       # vertical line (last election)
  geom_vline(xintercept = as.Date(enddate), color='#aaaaaabb')+         # vertical line (next election)
  geom_segment(aes(x=as.Date(startdate), xend=as.Date(enddate), y=5, yend=5), color='#666666bb', linetype='dashed')+      # horizontal line (election threshold 5%)
  # add poll points
  geom_point(aes_string(x='polldate',y=party1),size=ifelse(polls$polldate==startdate | polls$polldate==enddate,3,1.5),shape=ifelse(polls$polldate==startdate | polls$polldate==enddate,23,21),color=paste0(col1,transp),fill=paste0(col1,transp))+
  geom_point(aes_string(x='polldate',y=party2),size=ifelse(polls$polldate==startdate | polls$polldate==enddate,3,1.5),shape=ifelse(polls$polldate==startdate | polls$polldate==enddate,23,21),color=paste0(col2,transp),fill=paste0(col2,transp))+
  geom_point(aes_string(x='polldate',y=party3),size=ifelse(polls$polldate==startdate | polls$polldate==enddate,3,1.5),shape=ifelse(polls$polldate==startdate | polls$polldate==enddate,23,21),color=paste0(col3,transp),fill=paste0(col3,transp))+
  geom_point(aes_string(x='polldate',y=party4),size=ifelse(polls$polldate==startdate | polls$polldate==enddate,3,1.5),shape=ifelse(polls$polldate==startdate | polls$polldate==enddate,23,21),color=paste0(col4,transp),fill=paste0(col4,transp))+
  geom_point(aes_string(x='polldate',y=party5),size=ifelse(polls$polldate==startdate | polls$polldate==enddate,3,1.5),shape=ifelse(polls$polldate==startdate | polls$polldate==enddate,23,21),color=paste0(col5,transp),fill=paste0(col5,transp))+
  geom_point(aes_string(x='polldate',y=party6),size=ifelse(polls$polldate==startdate | polls$polldate==enddate,3,1.5),shape=ifelse(polls$polldate==startdate | polls$polldate==enddate,23,21),color=paste0(col6,transp),fill=paste0(col6,transp))+
  geom_point(aes_string(x='polldate',y=party7),size=ifelse(polls$polldate==startdate | polls$polldate==enddate,3,1.5),shape=ifelse(polls$polldate==startdate | polls$polldate==enddate,23,21),color=paste0(col7,transp),fill=paste0(col7,transp))+
  geom_point(aes_string(x='polldate',y=party8),size=ifelse(polls$polldate==startdate | polls$polldate==enddate,3,1.5),shape=ifelse(polls$polldate==startdate | polls$polldate==enddate,23,21),color=paste0(col8,transp),fill=paste0(col8,transp))+
  geom_point(aes_string(x='polldate',y=party9),size=ifelse(polls$polldate==startdate | polls$polldate==enddate,3,1.5),shape=ifelse(polls$polldate==startdate | polls$polldate==enddate,23,21),color=paste0(col9,transp),fill=paste0(col9,transp))+
  # add trend lines
  # the "span" (smoothing parameter) should be manually changed for individual parties that have less polling data
  geom_smooth(aes_string(x='polldate',y=party1,color=shQuote('col1')),method="loess",span=spansize,n=500,se=FALSE)+
  geom_smooth(aes_string(x='polldate',y=party2,color=shQuote('col2')),method="loess",span=spansize,n=500,se=FALSE)+
  geom_smooth(aes_string(x='polldate',y=party3,color=shQuote('col3')),method="loess",span=spansize,n=500,se=FALSE)+
  geom_smooth(aes_string(x='polldate',y=party4,color=shQuote('col4')),method="loess",span=spansize,n=500,se=FALSE)+
  geom_smooth(aes_string(x='polldate',y=party5,color=shQuote('col5')),method="loess",span=spansize,n=500,se=FALSE)+
  geom_smooth(aes_string(x='polldate',y=party6,color=shQuote('col6')),method="loess",span=spansize,n=500,se=FALSE)+
  geom_smooth(aes_string(x='polldate',y=party7,color=shQuote('col7')),method="loess",span=spansize,n=500,se=FALSE)+
  geom_smooth(aes_string(x='polldate',y=party8,color=shQuote('col8')),method="loess",span=spansize,n=500,se=FALSE)+
  geom_smooth(aes_string(x='polldate',y=party9,color=shQuote('col9')),method="loess",span=spansize,n=500,se=FALSE)+
  scale_y_continuous(labels = function(x) paste0(x, "%"),limits=c(0,62))+    # add %, manual limits on y-axis
  scale_x_date(limits = as.Date(c(startdate,enddate)), date_minor_breaks = "1 months", date_breaks = "3 months", date_labels = "%b %Y")+    # grid: 1 month, labels: 3 months
  labs(x = "", y = "")+
  scale_color_manual(name="",
                     breaks = c('col1','col2','col3','col4','col5','col6','col7','col8','col9'),
                     labels = c(party1,party2,party3,party4,party5,party6,party7,party8,party9),
                     values = c('col1'=col1,'col2'=col2,'col3'=col3,'col4'=col4,'col5'=col5,'col6'=col6,'col7'=col7,'col8'=col8,'col9'=col9))+
  # legend appearance
  theme(
    axis.text.x = element_text(size = 11),
    axis.text.y = element_text(size = 12),
    axis.title.y = element_text(size = 16),
    legend.position="right",
    legend.key.width=unit(24, "pt"),
    legend.key.height=unit(24, "pt"),
    legend.text = element_text(size=16, margin = margin(b = 5, t = 5, unit = "pt")))

graph + theme()

ggsave(file="polls.svg", plot=graph, width=18, height=10)

# workaround since svglite doesn't properly work in Wikipedia
aaa=readLines("polls.svg",-1)
bbb <- gsub(".svglite ", "", aaa)
writeLines(bbb,"polls.svg")
CAT.csv
polldate,Fidesz-KDNP,Jobbik,MSZP,Parbeszed,LMP,DK,Momentum,MKKP,Mi Hazank
2018-04-08,49.27,19.06,11.91,,7.06,5.38,3.06,1.73,
2018-04-23,49,18,15,,5,4,3,3,
2018-04-30,52,19,10,,6,6,4,2,
2018-05-09,48,18,15,,5,4,3,3,
2018-05-13,50,21,11,,6,6,3,1,
2018-05-22,54,19,9,,6,5,4,2,
2018-06-01,59,16,11,,3,7,3,0,
2018-06-11,55,17,9,2,5,6,2,3,
2018-06-13,48,16,16,,5,4,3,3,
2018-06-22,55,18,9,,6,5,4,2,
2018-07-06,53,13,14,,6,6,,,
2018-07-16,49,17,16,,5,4,2,3,0
2018-07-17,55,17,9,,5,7,4,2,1
2018-07-18,55,13,10,3,5,7,1,3,0
2018-08-14,54,17,9,,5,4,4,2,1
2018-08-16,52,16,15,,4,7,2,3,0
2018-08-18,56,14,10,,5,7,2,3,0
2018-09-10,53,14,13,,5,7,,,
2018-09-18,52,18,8,,5,8,3,1,1
2018-09-19,57,14,11,1,4,7,3,3,2
2018-09-19,53,14,15,,5,5,2,2,0
2018-09-26,60,11,9,,4,10,2,3,2
2019-05-22,52,15,14,,4,7,4,2,1
2019-05-19,54,10,10,,5,10,6,3,2
2019-05-18,55,12,11,,4,10,5,1,2
2019-05-18,51,9,7,,3,11,6,,3
2019-05-14,53,12,12,,5,11,4,2,2
2019-05-11,50,14,7,,5,8,6,4,2
2019-05-06,50,13,10,2,5,9,4,4,2
2019-04-26,57,11,10,,5,8,4,3,2
2019-04-25,57,6,12,1,4,11,5,2,1
2019-04-23,52,15,16,,4,7,6,0,0
2019-04-21,54,14,10,,4,9,4,,2
2019-04-15,53,12,12,1,4,9,4,2,2
2019-04-03,56,11,11,1,6,10,3,1,0
2019-04-01,48,14,10,2,4,9,6,3,2
2019-03-28,56,12,11,,5,6,4,4,2
2019-03-20,50,16,17,,2,4,4,4,1
2019-03-19,50,14,13,1,4,9,5,1,2
2019-03-04,47,17,10,2,3,9,4,4,2
2019-02-22,54,13,11,,5,6,4,4,3
2019-02-20,50,17,15,,3,5,4,2,0
2019-02-10,49,14,12,2,4,9,4,2,2
2019-01-28,47,16,10,2,3,9,6,4,1
2019-01-27,56,13,12,1,5,9,3,0,1
2019-01-27,54,13,10,,5,7,4,3,3
2019-01-16,47,17,16,,4,6,4,3,1
2019-01-13,53,13,12,,5,8,,,
2019-01-11,48,17,12,2,4,8,5,3,1
2018-12-20,50,11,10,3,4,9,5,4,1
2018-12-19,48,15,16,,4,6,4,3,1
2018-12-15,54,14,11,,4,7,4,3,3
2018-12-11,51,15,13,2,3,8,4,3,2
2018-12-05,59,12,10,,2,10,3,1,2
2018-12-03,51,12,10,2,3,9,5,4,2
2018-11-27,53,15,10,,4,7,4,4,2
2018-11-22,55,12,11,1,3,8,5,3,1
2018-11-21,54,13,14,,4,5,2,3,2
2018-10-29,51,17,10,,4,8,4,4,1
2018-10-22,55,18,8,1,3,7,2,4,1
2018-10-21,57,12,11,2,3,7,4,2,1
2018-10-17,63,11,8,1,2,9,3,1,1
2018-10-17,52,14,15,,4,5,2,3,1
2021-11-24,47,10,7,3,2,19,5,2,3
2021-11-23,41,10,7,4,3,15,9,4,3
2021-11-12,37,6,4,2,3,18,5,4,4
2021-10-29,42,11,7,2,3,16,10,3,2
2021-10-19,47,14,7,3,2,19,4,1,1
2021-10-16,44,3,1,,1,18,4,2,3
2021-10-04,44,13,8,2,2,18,9,2,1
2021-09-18,45,5,2,,1,13,4,2,1
2021-09-07,48,13,5,2,2,16,7,3,3
2021-08-28,45,15,7,2,3,17,8,1,1
2021-08-26,50,13,6,2,2,17,5,2,2
2021-08-01,47,13,5,2,2,16,9,4,3
2021-07-04,47,15,4,2,2,15,8,3,3
2021-06-08,46,15,5,2,2,16,9,2,2
2021-05-21,44,11,10,,2,12,8,1,1
2021-05-17,46,16,7,1,3,18,7,1,1
2021-05-11,54,14,2,1,2,13,8,2,1
2021-05-04,46,14,5,2,1,16,9,2,2
2021-04-28,48,10,9,1,1,11,8,1,1
2021-04-23,46,14,9,2,2,13,12,1,1
2021-04-22,47,15,7,1,2,17,8,1,1
2021-03-31,44,14,5,2,1,17,10,3,3
2021-03-11,47,14,3,2,3,9,9,2,3
2021-03-11,46,14,7,2,2,16,9,1,3
2021-02-25,45,10,9,1,1,12,9,1,1
2021-02-25,44,11,6,3,2,17,10,2,2
2021-02-22,46,11,8,2,2,15,13,3,1
2021-02-13,47,12,8,1,3,18,9,1,1
2021-01-21,46,8,8,3,2,16,13,2,2
2020-12-18,49,10,4,,2,11,13,5,3
2020-12-15,47,9,6,2,2,17,11,2,3
2020-12-15,46,8,8,3,2,15,14,2,2
2020-12-08,45,10,7,2,2,19,10,3,2
2020-12-04,47,9,7,2,3,17,10,2,2
2020-11-24,48,7,8,2,2,15,13,3,2
2020-11-23,48,8,10,2,1,13,11,1,1
2020-11-17,47,10,7,2,2,17,11,2,2
2020-11-05,48,8,6,2,3,17,10,2,2
2020-10-26,50,7,7,2,2,15,12,3,2
2020-10-20,51,12,6,1,2,12,10,3,2
2020-10-15,49,10,6,2,2,17,10,2,2
2020-10-04,50,8,6,2,2,17,10,2,2
2020-09-25,49,9,9,1,1,13,11,2,1
2020-09-18,50,9,6,2,2,18,10,1,2
2020-08-31,52,7,6,2,2,16,10,2,2
2020-08-31,48,8,10,2,2,14,10,2,2
2020-08-24,54,8,6,1,3,14,9,4,1
2020-08-19,51,8,6,2,2,15,10,2,3
2020-08-03,52,6,6,2,2,16,10,2,1
2020-07-15,52,7,5,1,3,15,11,3,3
2020-07-02,51,9,4,,3,11,16,4,1
2020-06-30,50,6,6,2,2,15,13,2,2
2020-06-10,51,7,11,,2,14,11,2,2
2020-06-05,52,9,4,,2,12,14,5,1
2020-06-05,50,7,7,2,2,12,12,4,2
2020-05-31,49,7,6,2,2,17,11,1,3
2020-05-22,50,8,12,,1,16,11,2,1
2020-05-08,54,9,3,,2,11,13,6,1
2020-04-26,50,7,7,2,2,16,12,1,2
2020-04-19,53,9,11,,3,15,8,0,1
2020-04-18,55,9,3,,1,12,11,5,1
2020-04-18,51,9,10,,2,13,9,2,1
2020-03-21,52,10,8,,2,13,7,1,2
2020-03-20,49,9,7,2,2,16,9,2,3
2020-03-14,51,10,4,1,3,10,13,5,2
2020-03-13,50,9,7,2,2,16,9,2,2
2020-03-10,48,10,12,,2,14,12,1,1
2020-02-27,55,11,6,1,4,13,7,1,1
2020-02-20,51,10,7,2,2,14,9,2,2
2020-02-12,47,9,6,2,3,16,10,3,3
2020-01-20,52,9,7,1,3,14,10,1,2
2020-01-16,50,10,5,,4,10,13,4,3
2019-12-20,47,10,11,0,2,12,12,3,1
2019-12-15,50,9,7,2,1,15,10,2,3
2019-12-05,54,10,7,,3,11,10,2,3
2019-12-03,49,7,5,2,2,17,12,3,2
2019-11-30,52,9,7,,3,10,11,4,3
2019-11-16,49,9,8,1,2,15,11,2,3
2019-10-31,51,9,7,2,2,14,9,2,3
2019-10-27,52,9,6,,3,11,13,3,2
2019-10-23,59,6,9,0,3,14,6,1,1
2019-10-22,50,10,10,,2,12,12,2,2
2019-09-26,62,7,10,,1,13,5,1,1
2019-09-25,54,8,7,2,3,11,10,0,3
2019-09-24,50,8,7,1,2,16,9,3,2
2019-09-15,54,7,8,,2,15,8,1,3
2019-08-26,53,8,6,,3,11,11,4,3
2019-08-17,52,10,10,,2,12,11,2,1
2019-08-14,53,9,7,1,2,14,7,2,3
2019-07-28,52,9,7,,3,11,11,4,3
2019-07-26,48,9,6,1,3,18,8,4,2
2019-07-23,51,10,10,,2,11,10,2,2
2019-07-14,51,8,7,1,2,17,7,3,3
2019-07-02,57,8,8,,2,17,6,1,1
2019-06-27,52,10,10,,3,12,11,1,1
2019-06-26,53,8,6,,3,12,10,5,2
2019-06-14,53,7,7,1,2,17,9,2,3
2019-06-09,49,9,8,2,2,15,9,3,2
2022-01-25,46,11,7,3,2,16,7,3,3
2022-01-14,48,11,4,2,1,17,9,3,4
2021-12-14,43,10,7,3,3,16,9,3,4
2021-12-13,47,11,3,2,1,18,10,3,4
2021-12-11,40,11,2,1,2,10,7,4,5
2021-11-30,46,9,10,,1,13,6,0,1
2022-03-11,50,12,4,2,1,17,7,3,3
2022-03-05,58,4,3,,1,14,5,3,4
2022-02-10,50,11,6,3,2,17,5,2,4
2022-02-09,49,11,4,2,1,17,8,3,4

Date
Source Travail personnel
Auteur PLATEL

Conditions d’utilisation

Moi, en tant que détenteur des droits d’auteur sur cette œuvre, je la publie sous la licence suivante :
w:fr:Creative Commons
paternité partage à l’identique
Vous êtes libre :
  • de partager – de copier, distribuer et transmettre cette œuvre
  • d’adapter – de modifier cette œuvre
Sous les conditions suivantes :
  • paternité – Vous devez donner les informations appropriées concernant l'auteur, fournir un lien vers la licence et indiquer si des modifications ont été faites. Vous pouvez faire cela par tout moyen raisonnable, mais en aucune façon suggérant que l’auteur vous soutient ou approuve l’utilisation que vous en faites.
  • partage à l’identique – Si vous modifiez, transformez ou vous basez sur cet élément, vous devez distribuer votre contribution sous une license identique ou compatible à celle de l’original.

Légendes

Ajoutez en une ligne la description de ce que représente ce fichier

Éléments décrits dans ce fichier

dépeint

image/svg+xml

334 946 octet

865fab69e962d9f49d9b2d90d44e4c94a109a81a

Historique du fichier

Cliquer sur une date et heure pour voir le fichier tel qu'il était à ce moment-là.

Date et heureVignetteDimensionsUtilisateurCommentaire
actuel31 mars 2022 à 19:34Vignette pour la version du 31 mars 2022 à 19:341 620 × 900 (327 kio)wikimediacommons>BeimelJUpdated using 4 new polling results from feb. and mar.

La page suivante utilise ce fichier :