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

Le contenu de la page n’est pas pris en charge dans d’autres langues.
Une page de Wikipédia, l'encyclopédie libre.

Fichier d’origine(Fichier SVG, nominalement de 1 620 × 900 pixels, taille : 84 kio)

Ce fichier et sa description proviennent de Wikimedia Commons.

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.3         # general smoothing parameter for trend line
startdate <- '2020-11-01'   # 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]

# define party colors (taken from https://en.wikipedia.org/wiki/Category:Germany_political_party_colour_templates)
col1 <- '#FF6A00'
col2 <- '#20B2AA'
col3 <- '#808080'
col4 <- '#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))+
  # 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')),span=spansize,se=FALSE)+
  geom_smooth(aes_string(x='polldate',y=party2,color=shQuote('col2')),span=spansize,se=FALSE)+
  geom_smooth(aes_string(x='polldate',y=party3,color=shQuote('col3')),span=spansize,se=FALSE)+
  geom_smooth(aes_string(x='polldate',y=party4,color=shQuote('col4')),span=spansize,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'),
                     labels = c(party1,party2,party3,party4),
                     values = c('col1'=col1,'col2'=col2,'col3'=col3,'col4'=col4))+
  # 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,Opposition,MKKP,MHM
2022-03-27,50,46,1,3
2022-03-23,52,41,3,3
2022-03-18,49,46,,
2022-03-19,50,41,2,5
2022-03-21,49,41,3,2
2022-03-11,50,43,3,4
2022-03-05,54,46,,
2022-02-26,49,43,3,4
2022-02-24,48,46,3,3
2022-02-15,50,43,3,3
2022-02-11,54,41,2,3
2022-02-10,49,46,2,3
2022-02-09,49,44,3,4
2022-01-26,51,43,3,3
2022-01-25,47,47,3,3
2022-01-19,49,44,3,4
2022-01-14,43,39,5,3
2022-01-14,48,44,4,4
2022-01-05,50,43,3,3
2021-12-23,54,45,,
2021-12-15,55,43,,
2021-12-14,43,48,3,4
2021-12-11,46,32,4,5
2021-12-13,47,47,2,3
2021-12-07,44,45,6,5
2021-12-13,47,45,3,4
2021-11-30,46,53,0,1
2021-11-23,41,48,4,3
2021-11-24,48,49,2,2
2021-11-11,55,44,,
2021-11-05,48,45,3,3
2021-11-03,56,42,,
2021-10-29,42,51,2,3
2021-10-27,56,42,,
2021-10-21,55,44,,
2021-10-20,56,43,,
2021-10-13,56,42,,
2021-10-09,47,47,3,3
2021-10-06,44,47,5,4
2021-10-06,54,43,,
2021-10-04,44,52,2,1
2021-10-04,44,52,2,1
2021-09-29,54,44,,
2021-09-21,53,45,,
2021-09-20,49,49,,
2021-09-07,49,45,3,3
2021-08-28,45,52,1,1
2021-08-26,50,45,2,2
2021-08-25,52,46,,
2021-08-01,48,44,4,3
2021-07-04,47,45,3,4
2021-06-16,47,50,,
2021-06-09,52,43,2,3
2021-06-08,50,42,4,4
2021-06-08,46,49,2,2
2021-05-21,44,54,1,1
2021-05-17,48,50,,
2021-05-11,53,45,1,1
2021-05-04,46,48,2,4
2021-04-28,51,43,2,3
2021-04-28,48,51,1,1
2021-04-23,46,52,1,1
2021-04-22,48,49,1,1
2021-03-31,44,48,3,4
2021-03-25,45,53,1,1
2021-03-09,53,44,1,1
2021-03-11,54,40,2,3
2021-03-11,46,50,1,3
2021-02-25,45,48,3,3
2021-02-25,45,54,,
2021-02-22,46,51,2,1
2021-02-13,47,50,,
2021-01-26,44,47,4,3
2021-01-20,52,45,1,1
2021-01-21,46,50,2,2
2020-12-16,51,43,3,2
2020-12-15,47,47,2,3
2020-12-15,46,50,2,2
2020-12-08,48,52,,
2020-12-22,56,44,,
2020-11-21,48,50,,
2020-11-25,49,50,,
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 cette œuvre, vous devez distribuer votre contribution sous la même licence ou une licence compatible avec 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

Historique du fichier

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

Date et heureVignetteDimensionsUtilisateurCommentaire
actuel29 novembre 2022 à 13:01Vignette pour la version du 29 novembre 2022 à 13:011 620 × 900 (84 kio)PLATELfinal result
30 mars 2022 à 22:27Vignette pour la version du 30 mars 2022 à 22:271 620 × 900 (77 kio)BeimelJusing new polling results to update chart. i did just use the polling results which were summed up at or near 100 percent
3 février 2022 à 01:14Vignette pour la version du 3 février 2022 à 01:141 620 × 900 (63 kio)PLATELupdate
16 décembre 2021 à 03:36Vignette pour la version du 16 décembre 2021 à 03:361 620 × 900 (54 kio)PLATELUploaded own work with UploadWizard

La page suivante utilise ce fichier :

Usage global du fichier

Les autres wikis suivants utilisent ce fichier :

Métadonnées