Created
April 27, 2026 21:04
-
-
Save thoughtfulbloke/14fdd06ce0977d40ea87647625c716d9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # The microsoft report whose number use makesme sad | |
| # New Zealand’s Generative AI opportunity | |
| # https://msftstories.thesourcemediaassets.com/sites/433/2024/08/New-Zealands-Generative-AI-Opportunity.pdf | |
| # impact to date | |
| # UNDERSTANDING AOTEAROA NEW ZEALAND: THE IPSOS AI MONITOR 2025 | |
| # https://www.ipsos.com/sites/default/files/ct/news/documents/2025-08/Ipsos-AI-Monitor-2025%20NZ%20version.pdf | |
| # productivity | |
| # https://infoshare.stats.govt.nz | |
| # Economic Indicators - Productivity Statistics - PRD | |
| # Table: Productivity Indexes (ANZSIC06) (Annual-Mar) | |
| library(ggplot2) | |
| library(scales) | |
| library(systemfonts) | |
| # Theme, look, and style stuff ---------------------------- | |
| dual_ax_L <- "#E69F00" | |
| dual_ax_R <- "#56B4E9" | |
| offwhite_shade <- "#FDFDFDFD" | |
| # These are the font declarations for my Mac w. Lexend Deca added | |
| # Your kind of computer may be different | |
| bodyfont <- "Lexend Deca Thin" | |
| systemfonts::register_variant(name = bodyfont, | |
| family = "Lexend Deca", | |
| weight = "ultralight" | |
| ) | |
| headfont <- "Lexend Deca Medium" | |
| systemfonts::register_variant( | |
| name = headfont, | |
| family = "Lexend Deca", | |
| weight = "medium" | |
| ) | |
| theme_david_splitaxis <- function(){ | |
| theme_minimal(base_family=bodyfont, | |
| header_family=headfont, | |
| base_size = 9, | |
| ink = "#000000", | |
| paper = "#FFFFFF", | |
| accent = "red") %+replace% | |
| theme(text=element_text(family=bodyfont), | |
| axis.line = element_line(linewidth=0.2), | |
| axis.line.y.left = element_blank(), | |
| axis.line.y.right = element_blank(), | |
| axis.text.y.left = element_text(color = dual_ax_L, margin = margin(t = 5, r = 5, b = 5, l = 5, unit = "pt")), | |
| axis.text.y.right = element_text(color = dual_ax_R, margin = margin(t = 5, r = 5, b = 5, l = 5, unit = "pt")), | |
| axis.ticks = element_line(linewidth=0.2), | |
| axis.ticks.y.left = element_line(color = dual_ax_L), | |
| axis.ticks.y.right = element_line(color = dual_ax_R), | |
| axis.title = element_text(size = 9), | |
| axis.title.x.bottom = element_text(margin = margin(t = 7, r = 5, b = 0, l = 5, unit = "pt")), | |
| axis.title.y.left = element_text(color = dual_ax_L, hjust = .9, margin = margin(t = 5, r = 7, b = 5, l = 7, unit = "pt")), | |
| axis.title.y.right = element_text(color = dual_ax_R, hjust = .1, margin = margin(t = 5, r = 7, b = 5, l = 7, unit = "pt")), | |
| panel.background = element_rect(fill = "#FFFFFF", colour = NA, linewidth=NULL), | |
| panel.grid = element_blank(), | |
| panel.spacing = unit(1, "lines"), | |
| plot.background = element_rect(fill = offwhite_shade, colour=offwhite_shade), | |
| plot.caption = element_text(margin=margin(t = 5, r = 5, b = 5, l = 5, unit = "pt"), lineheight = 1.15, size=8, hjust=1), | |
| plot.caption.position = "plot", | |
| plot.margin = margin(t=10,r=10,b=10,l=10), | |
| plot.subtitle = element_text(lineheight = 1.18, size=10, margin=margin(t = 0, r = 5, b = 20, l = 10, unit = "pt"), hjust=0), | |
| plot.title = element_text(lineheight = 1.18, size=12, margin=margin(t = 5, r = 5, b = 10, l = 10, unit = "pt"), hjust=0, vjust=0), | |
| plot.title.position = "plot", | |
| # strip titles are inside the facets, not that this one is a facet graph | |
| strip.background = element_blank(), | |
| strip.clip = "off", | |
| strip.text = element_text(margin = margin_part(b = -15, l = 6), hjust=0, size = rel(1), colour="#00000099") | |
| ) | |
| } | |
| # Graph data ------------------------------------------- | |
| d28 <- data.frame(Yearis = c(2023,2024,2025), | |
| Productivity = c(0,-0.6,-1.47), | |
| AI.change = c(0,2,6)) | |
| # left = AI.change | |
| # right = productivity | |
| left_title = "% change in people\nimpacted by AI since 2023" | |
| right_title = "% change in Total Multifactor\nProductivity since 2023" | |
| # am mapping into an underlying 0 to 1 range | |
| # this code was developed to use part ranges | |
| # so the two sides can display as part ranges | |
| # for a classic double axis graph set both mins to 0 and maxs to 1 | |
| # and don't plot the rect annotations | |
| yleftlow = 0.51 | |
| ylefthigh = 1 | |
| yrightlow = 0 | |
| yrighthigh = 0.49 | |
| # ranges before | |
| left_orginal_range <- range(d28$AI.change, na.rm = TRUE) | |
| right_orginal_range <- range(d28$Productivity, na.rm = TRUE) | |
| # scaled variables in their respective new ranges | |
| # Create scaled variables in [0,1] space | |
| d28$left_scale <- rescale(d28$AI, to = c(yleftlow, ylefthigh), from = left_orginal_range) | |
| d28$right_scale <- rescale(d28$Productivity, to = c(yrightlow, yrighthigh), from = right_orginal_range) | |
| # labels will need converting back to original values, so make inverse functions | |
| # Inverse transform for left axis | |
| inv_left <- function(y) { | |
| rescale(y, from = c(yleftlow, ylefthigh), to = left_orginal_range) | |
| } | |
| # Inverse transform for right axis | |
| inv_right <- function(y) { | |
| rescale(y, from = c(yrightlow, yrighthigh), to = right_orginal_range) | |
| } | |
| # Make the graph ----------------------------------------------- | |
| ggplot(d28, aes(x = Yearis)) + | |
| # A bit of shading might be nice if the areas are not the same | |
| annotate("rect", xmin = -Inf, xmax = Inf, ymin=yleftlow, ymax=ylefthigh, | |
| fill = dual_ax_L, alpha=.05) + | |
| annotate("rect", xmin = -Inf, xmax = Inf, ymin=yrightlow, ymax=yrighthigh, | |
| fill = dual_ax_R, alpha=.05) + | |
| #but all the rest applies even if both axes are 0 to 1 | |
| geom_line(aes(y = left_scale), colour = dual_ax_L, linewidth = 0.5) + | |
| geom_line(aes(y = right_scale), colour = dual_ax_R, linewidth = 0.5) + | |
| annotate("segment", x = -Inf, xend = -Inf, | |
| y = yleftlow, yend = ylefthigh, | |
| colour = dual_ax_L, linewidth = 0.5) + | |
| annotate("segment", x = Inf, xend = Inf, | |
| y = yrightlow, yend = yrighthigh, | |
| colour = dual_ax_R, linewidth = 0.5) + | |
| theme_david_splitaxis()+ | |
| # left = AI.change | |
| scale_y_continuous( | |
| limits = c(0, 1), | |
| breaks = seq(yleftlow, ylefthigh, length.out=3), | |
| labels = function(y) round(inv_left(y), 2), | |
| name = left_title, | |
| sec.axis = sec_axis( | |
| ~ ., | |
| breaks = seq(yrightlow, yrighthigh, length.out=3), | |
| labels = function(y) round(inv_right(y), 2), | |
| name = right_title | |
| ) | |
| ) + | |
| scale_x_continuous(breaks=2023:2025) + | |
| labs( | |
| x = NULL, | |
| title = "Last week Microsoft cited up to 102 billion added to NZ GDP by 2038 | |
| through increasing AI use increasing national productivity.", | |
| subtitle = "As that model began in 2023, it has gone along for long enough to actually check | |
| the relationship between how AI and productivity changed since 2023", | |
| caption = "Source: IPSOS AI MONITOR 2025 people who AI has changed their life | |
| Productivity: Stats NZ Infoshare - Economic Indicators - Productivity Statistics | |
| Made by David Hood, 2026-04-28") | |
| ggsave( | |
| filename = "ggskyd28v2.jpg", | |
| width = 2016, | |
| height = 1134, | |
| units = "px" | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment