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

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Original file(SVG file, nominally 1,620 × 900 pixels, file size: 327 KB)

Captions

Captions

Add a one-line explanation of what this file represents

Summary[edit]

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 Own work
Author PLATEL

Licensing[edit]

I, the copyright holder of this work, hereby publish it under the following license:
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current18:34, 31 March 2022Thumbnail for version as of 18:34, 31 March 20221,620 × 900 (327 KB)BeimelJ (talk | contribs)Updated using 4 new polling results from feb. and mar.
23:00, 2 February 2022Thumbnail for version as of 23:00, 2 February 20221,620 × 900 (321 KB)PLATEL (talk | contribs)update
00:53, 16 December 2021Thumbnail for version as of 00:53, 16 December 20211,620 × 900 (261 KB)PLATEL (talk | contribs)Uploaded own work with UploadWizard

There are no pages that use this file.

File usage on other wikis

Metadata