Jump to content

File:Opinion polling for the 2024 Icelandic parliamentary election.svg

Page contents not supported in other languages.
This is a file from the Wikimedia Commons
From Wikipedia, the free encyclopedia

Original file (SVG file, nominally 1,728 × 768 pixels, file size: 314 KB)

Summary

Description
English: Opinion polling for the 2024 Icelandic 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)
library(Rcpp)

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

spansize <- 0.185           # general smoothing parameter for trend line
nnum <- 1000                 # number of points used for trendline (resolution)
startdate <- '2021-09-25'   # date of previous election
enddate <- '2024-11-30'     # (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]
party10 <- colnames(polls)[11]
party11 <- colnames(polls)[12]

# define party colors (taken from https://en.wikipedia.org/wiki/Category:Germany_political_party_colour_templates)
col1 <- '#00ADEF'
col2 <- '#87FF91'
col3 <- '#00B878'
col4 <- '#ED1400'
col5 <- '#FFCA3E'
col6 <- '#976dff'
col7 <- '#ff7d14'
col8 <- '#141f6e'
col9 <- '#EF4839'
col10 <- '#04437F'
col11 <- '#322757'

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))+
  geom_point(aes_string(x='polldate',y=party10),size=ifelse(polls$polldate==startdate | polls$polldate==enddate,3,1.5),shape=ifelse(polls$polldate==startdate | polls$polldate==enddate,23,21),color=paste0(col10,transp),fill=paste0(col10,transp))+
  geom_point(aes_string(x='polldate',y=party11),size=ifelse(polls$polldate==startdate | polls$polldate==enddate,3,1.5),shape=ifelse(polls$polldate==startdate | polls$polldate==enddate,23,21),color=paste0(col11,transp),fill=paste0(col11,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=nnum,se=FALSE)+
  geom_smooth(aes_string(x='polldate',y=party2,color=shQuote('col2')),method="loess",span=spansize,n=nnum,se=FALSE)+
  geom_smooth(aes_string(x='polldate',y=party3,color=shQuote('col3')),method="loess",span=spansize,n=nnum,se=FALSE)+
  geom_smooth(aes_string(x='polldate',y=party4,color=shQuote('col4')),method="loess",span=spansize,n=nnum,se=FALSE)+
  geom_smooth(aes_string(x='polldate',y=party5,color=shQuote('col5')),method="loess",span=spansize,n=nnum,se=FALSE)+
  geom_smooth(aes_string(x='polldate',y=party6,color=shQuote('col6')),method="loess",span=spansize,n=nnum,se=FALSE)+
  geom_smooth(aes_string(x='polldate',y=party7,color=shQuote('col7')),method="loess",span=spansize,n=nnum,se=FALSE)+
  geom_smooth(aes_string(x='polldate',y=party8,color=shQuote('col8')),method="loess",span=spansize,n=nnum,se=FALSE)+
  geom_smooth(aes_string(x='polldate',y=party9,color=shQuote('col9')),method="loess",span=spansize,n=nnum,se=FALSE)+
  geom_smooth(aes_string(x='polldate',y=party10,color=shQuote('col10')),method="loess",span=1.75,n=nnum,se=FALSE)+
  geom_smooth(aes_string(x='polldate',y=party11,color=shQuote('col11')),method="loess",span=1.75,n=nnum,se=FALSE)+
  scale_y_continuous(labels = function(x) paste0(x, "%"),limits=c(0,31))+    # 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','col10','col11'),
                     labels = c(party1,party2,party3,party4,party5,party6,party7,party8,party9,party10,party11),
                     values = c('col1'=col1,'col2'=col2,'col3'=col3,'col4'=col4,'col5'=col5,'col6'=col6,'col7'=col7,'col8'=col8,'col9'=col9,'col10'=col10,'col11'=col11))+
  # 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=8)

# 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,D,B,V,S,F,P,C,M,J,L,Y
2024-11-30,19.36,7.80,2.34,20.75,13.78,3.02,15.82,12.10,3.96,1.04,0.02
2024-11-29,18.4,6.8,3.1,20.0,12.6,4.1,17.6,11.2,4.8,1.4,0.0
2024-11-28,14.7,6.4,3.4,21.8,11.2,5.5,17.6,12.0,5.8,1.2,0.4
2024-11-28,14.5,7.8,3.7,20.4,10.8,5.4,19.2,11.6,5,1.1,0.5
2024-11-22,11.5,4.4,3,18.3,12.5,6.7,22,13.5,6.4,1,0.7
2024-11-21,16,6.2,3.3,20.2,13.1,4.1,18.1,12.2,5.1,,
2024-11-20,14.6,5.9,3.1,22.7,8.8,4.3,20.9,12.6,5.0,1.6,0.6
2024-11-14,12,5.6,2.4,22.4,10.2,3.4,21.5,15.5,5.4,1,0.6
2024-11-14,16.4,6,4.1,20.8,10.2,5.5,15.5,14.3,6.2,1,0.1
2024-11-13,13.4,7.3,3.4,20.1,9.2,5.1,19.9,12.6,6.3,2.1,0.6
2024-11-07,12.3,5.8,2.6,21.6,11.5,5.7,17.1,15.1,6.7,1.4,0.2
2024-11-06,13.3,7.5,3.2,20.9,8.9,4.9,19.4,14.9,4.5,1.7,0.8
2024-10-31,17.3,6.5,4.1,23.8,7.8,5.4,13.5,16.5,4.5,0.6,0
2024-10-31,14.1,5.8,2.6,22.3,11.2,4.9,18.5,14.4,4.0,1.5,0.5
2024-10-28,13.9,6.9,3.8,22.2,9.3,4.5,16.2,15.9,4.0,1.6,0.9
2024-10-24,13.3,5.8,2.4,24.2,11.4,5.8,15.0,16.1,4.3,1.1,0.4
2024-10-18,15.6,6.2,2.2,24.8,10.8,6.1,14.1,15.1,4.2,,
2024-10-18,14.1,8,5.1,21.9,7.3,5.2,13.4,17.7,5.2,2.1,
2024-10-03,12,5,3,26,11,9,11,18,4,,
2024-09-30,14.1,6.2,4.3,26.2,7.5,7.6,10.3,18.7,5.2,,
2024-09-24,13.4,7.6,3.7,25,8.8,8.5,11.3,17.0,4.7,,
2024-08-29,17.1,7.0,3.4,26.4,6.7,7.8,10.1,16.0,5.7,,
2024-08-27,13.9,9.0,4.6,25.5,7.1,8.6,10.7,15.3,5.2,,
2024-07-30,17.2,7.2,3.5,27.6,8.6,7.8,8.8,14.6,4.7,,
2024-06-30,18.5,6.6,4.0,26.9,7.7,8.8,9.4,14.5,3.5,,
2024-06-20,14.7,10.2,5.0,27.1,5.0,9.3,10.1,12.7,5.9,,
2024-06-02,18.0,9.1,3.3,29.9,6.1,8.8,7.7,13.5,3.7,,
2024-05-23,17.5,10.4,5.1,27.3,5.6,8.4,9.3,12.6,3.9,,
2024-04-30,19.0,10.0,4.3,25.4,7.3,8.1,7.9,13.4,4.4,,
2024-04-28,18.0,8.8,4.4,29.7,7.2,8.2,7.5,12.8,3.4,,
2024-04-16,17.2,10.7,5.0,27.3,5.3,8.5,10.2,11.6,4.1,,
2024-04-02,18.2,7.3,5.6,30.9,6.2,7.8,7.1,12.9,3.9,,
2024-03-12,18.0,9.4,6.7,25.6,5.7,9.5,9.7,11.9,3.5,,
2024-02-29,19.9,8.8,4.7,28.2,6.8,8.0,7.5,12.8,3.5,,
2024-02-27,18.4,8.5,5.9,27.2,6.4,9.0,9.2,11.1,4.3,,
2024-01-31,18.2,8.4,5.5,30.6,7.9,8.1,7.0,10.9,3.4,,
2024-01-15,16.6,10.3,5.7,25.7,6.5,7.6,11.7,11.8,4.1,,
2024-01-01,18.1,9.4,6.0,28.4,6.8,9.1,8.8,9.7,3.6,,
2023-12-27,17.3,9.9,5.6,26.3,6.8,8.1,12.2,9.4,4.3,,
2023-11-30,19.8,8.6,5.1,28.1,6.9,9.3,7.9,9.4,4.2,,
2023-11-26,17.9,10.4,6.1,26.0,6.4,10.0,10.3,8.4,4.4,,
2023-10-31,20.5,7.4,6.0,29.1,6.5,10.2,7.5,8.6,4.1,,
2023-10-24,17.7,9.8,5.9,27.8,6.1,10.8,9.3,8.2,4.3,,
2023-10-03,20.4,8.1,5.7,30.1,5.7,9.6,7.9,8.6,3.9,,
2023-09-29,19.6,8.8,6.5,24.4,6.5,10.8,11.6,7.0,4.8,,
2023-08-31,21.1,7.5,5.9,28.5,6.3,10.3,7.2,8.7,4.4,,
2023-08-22,17.6,9.2,6.4,26.1,5.9,13.1,9.5,7.9,4.2,,
2023-07-30,21.0,8.9,6.1,28.6,5.7,10.5,7.0,8.5,3.6,,
2023-07-24,19.3,9.6,8.0,25.3,6.0,11.0,10.4,5.9,4.5,,
2023-07-22,16.1,7.1,7.3,27.4,8.5,14.5,8.9,7.2,2.9,,
2023-07-02,20.8,8.7,6.2,28.4,5.7,9.7,8.1,7.8,4.6,,
2023-06-22,18.5,8.8,7.0,27.2,6.6,11.3,9.7,6.3,4.7,,
2023-05-31,20.8,10.2,5.7,28.4,5.5,10.1,7.6,6.9,4.9,,
2023-05-16,19.2,10.0,6.1,27.3,5.6,11.0,9.1,6.4,5.2,,
2023-05-01,21.9,9.6,6.6,27.8,6.0,10.0,7.4,6.2,4.3,,
2023-04-19,18.7,10.2,8.2,25.7,4.4,11.4,10.6,6.0,4.9,,
2023-04-04,22.3,9.9,7.1,25.1,5.6,9.4,9.1,6.3,5.1,,
2023-03-20,20.2,13.2,6.0,24.4,5.2,10.2,9.1,5.7,6.0,,
2023-02-28,22.5,10.8,6.8,24.0,5.6,12.1,7.7,5.3,5.0,,
2023-02-13,20.1,12.3,6.7,23.3,5.9,12.7,8.2,5.8,5.0,,
2023-02-06,23.2,11.8,5.9,22.1,9.5,12.5,6.9,4.1,4.1,,
2023-01-18,21.8,12.1,8.3,23.6,5.1,10.4,9.1,5.9,3.6,,
2023-01-31,23.5,11.3,6.8,25.3,5.5,10.4,7.3,5.5,4.4,,
2023-01-02,23.8,12.1,6.8,23.4,6.2,11.3,6.9,4.6,4.6,,
2022-12-30,23.2,10.8,6.7,20.5,9.7,14.3,6.2,4.5,4.0,,
2022-12-28,20.0,12.2,7.8,20.1,7.0,12.5,7.5,6.7,6.1,,
2022-11-30,24.1,12.2,7.5,21.1,4.5,12.2,7.4,5.6,5.2,,
2022-11-22,21.8,14.8,7.1,19.0,5.0,13.4,9.0,4.9,5.0,,
2022-11-17,21.1,14.6,8.0,19.1,6.4,11.8,10.6,4.2,4.2,,
2022-10-31,24.4,13.8,8.4,16.6,5.3,12.9,8.4,5.0,5.0,,
2022-10-17,22.8,15.0,7.7,14.4,4.6,14.3,9.5,5.0,6.5,,
2022-10-02,24.1,13.4,8.2,16.3,5.1,13.6,8.5,5.4,5.1,,
2022-09-27,20.8,15.6,8.7,15.2,5.0,12.3,10.4,5.3,6.8,,
2022-08-31,21.8,15.6,8.4,15.5,5.6,14.8,8.4,4.6,5.1,,
2022-08-17,20.9,19.6,7.5,12.9,4.6,13.9,8.9,4.5,7.3,,
2022-08-01,22.1,15.4,8.6,13.7,6.6,15.0,8.6,4.4,5.3,,
2022-07-25,24.4,18.0,7.7,10.9,6.9,12.7,8.3,6.0,5.1,,
2022-06-30,22.8,17.5,7.2,13.7,7.0,16.1,6.7,4.6,4.1,,
2022-06-23,19.3,18.3,8.5,13.4,6.3,14.6,8.8,4.7,6.1,,
2022-06-13,18.5,17.3,9.0,13.5,5.6,17.5,7.8,4.2,6.3,,
2022-05-31,20.1,17.5,8.1,14.1,6.4,14.7,9.5,4.3,5.0,,
2022-04-26,17.9,12.4,9.6,16.8,8.0,16.2,9.6,4.1,5.4,,
2022-04-30,19.8,15.6,10.1,13.7,7.7,14.5,9.6,4.1,4.6,,
2022-04-12,22.4,15.5,8.8,13.0,7.7,13.2,10.5,4.2,4.6,,
2022-03-31,22.7,18.0,11.4,11.2,8.2,11.9,9.1,3.7,3.6,,
2022-02-28,21.9,18.1,10.5,11.1,7.5,13.2,9.7,3.9,3.9,,
2022-02-16,21.9,16.9,12.9,13.4,7.6,10.3,9.7,3.9,3.5,,
2022-01-31,22.4,17.0,10.7,10.8,8.8,12.5,9.4,3.7,4.3,,
2022-01-19,20.1,17.8,11.2,12.3,8.5,13.5,9.2,3.7,3.7,,
2021-12-30,23.3,17.7,10.6,10.5,8.6,12.5,8.7,3.4,4.5,,
2021-11-30,22.7,17.0,13.0,10.7,8.0,11.8,8.4,3.8,4.4,,
2021-10-31,22.8,17.2,13.4,9.8,7.9,11.0,8.9,4.3,4.6,,
2021-10-18,21.1,17.9,12.1,10.1,7.8,11.7,10.0,3.2,5.5,,
2021-09-25,24.39,17.27,12.57,9.93,8.85,8.63,8.33,5.45,4.10,,
Date
Source Own work
Author PLATEL

Licensing

I, the copyright holder of this work, hereby publish it under the following license:
Creative Commons CC-Zero This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication.
The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.

Captions

Opinion polling for the 2024 Icelandic parliamentary election using local regressions (LOESS)

Items portrayed in this file

depicts

21 October 2024

image/svg+xml

File history

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

Date/TimeThumbnailDimensionsUserComment
current17:50, 2 December 2024Thumbnail for version as of 17:50, 2 December 20241,728 × 768 (314 KB)PLATELupd
06:03, 23 November 2024Thumbnail for version as of 06:03, 23 November 20241,728 × 768 (305 KB)PLATELupd
23:30, 17 November 2024Thumbnail for version as of 23:30, 17 November 20241,728 × 768 (301 KB)PLATELupd
17:56, 10 November 2024Thumbnail for version as of 17:56, 10 November 20241,728 × 768 (296 KB)PLATEL2024 colours upd
15:01, 10 November 2024Thumbnail for version as of 15:01, 10 November 20241,728 × 768 (296 KB)PLATELupd
10:11, 3 November 2024Thumbnail for version as of 10:11, 3 November 20241,728 × 768 (277 KB)PLATELupd
14:41, 2 November 2024Thumbnail for version as of 14:41, 2 November 20241,728 × 768 (275 KB)PLATELupd
03:15, 22 October 2024Thumbnail for version as of 03:15, 22 October 20241,620 × 900 (466 KB)GlowstoneUnknownmore vertical res
08:33, 21 October 2024Thumbnail for version as of 08:33, 21 October 20241,728 × 768 (206 KB)PLATELdarker B
08:29, 21 October 2024Thumbnail for version as of 08:29, 21 October 20241,728 × 768 (206 KB)PLATELUploaded own work with UploadWizard

The following page uses this file:

Global file usage

The following other wikis use this file:

Metadata