diff --git a/Makefile b/Makefile index f7b2c55..1fcf77b 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ docker: documentation: jb clean docs && jb build docs - python docs/add_plotly_to_book.py docs/book + python docs/add_plotly_to_book.py docs data: python policyengine_uk_data/datasets/frs/dwp_frs.py diff --git a/docs/constituency_methodology.ipynb b/docs/constituency_methodology.ipynb index aba38e2..6df86b7 100644 --- a/docs/constituency_methodology.ipynb +++ b/docs/constituency_methodology.ipynb @@ -950,112 +950,6 @@ "```" ] }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": {}, - "outputs": [], - "source": [ - "# import pandas as pd\n", - "# import numpy as np\n", - "# import matplotlib.pyplot as plt\n", - "\n", - "# # Sample data for Darlington\n", - "# income_data = {\n", - "# 'parliamentary constituency 2010': ['Darlington'],\n", - "# 'constituency_code': ['E14000658'],\n", - "# 'Number of jobs': ['31000'],\n", - "# '10 percentile': [13298.0],\n", - "# '20 percentile': [16723.0],\n", - "# '30 percentile': [20778.0],\n", - "# '40 percentile': [23407.0],\n", - "# '50 percentile': [27158.0],\n", - "# '60 percentile': [30471.0],\n", - "# '70 percentile': [33812.0],\n", - "# '80 percentile': [40717.0],\n", - "# '90 percentile': [55762.0],\n", - "# '91 percentile': [58878.0],\n", - "# '92 percentile': [62394.4],\n", - "# '93 percentile': [66722.3],\n", - "# '94 percentile': [71952.0],\n", - "# '95 percentile': [78804.5],\n", - "# '96 percentile': [87640.7],\n", - "# '97 percentile': [100083.5],\n", - "# '98 percentile': [123526.5],\n", - "# '100 percentile': [179429.0]\n", - "# }\n", - "\n", - "# income_sample = pd.DataFrame(income_data)\n", - "\n", - "# # Excel Data Method\n", - "# def load_real_data():\n", - "# # Read Excel data\n", - "# income_real = pd.read_excel(\"nomis_earning_jobs_data.xlsx\", skiprows=7)\n", - "# income_real.columns = income_real.iloc[0]\n", - "# income_real = income_real.drop(index=0).reset_index(drop=True)\n", - " \n", - "# # Select and rename columns\n", - "# columns_to_keep = [\n", - "# 'parliamentary constituency 2010',\n", - "# 'constituency_code',\n", - "# 'Number of jobs',\n", - "# 'Median',\n", - "# '10 percentile',\n", - "# '20 percentile',\n", - "# '30 percentile',\n", - "# '40 percentile',\n", - "# '60 percentile',\n", - "# '70 percentile',\n", - "# '80 percentile',\n", - "# '90 percentile'\n", - "# ]\n", - "# income_real = income_real[columns_to_keep]\n", - "# income_real = income_real.rename(columns={'Median': '50 percentile'})\n", - "# return income_real\n", - "\n", - "# # Plotting function\n", - "# def plot_constituency_distribution(income_df, constituency_name, detailed=True):\n", - "# constituency_data = income_df[income_df['parliamentary constituency 2010'] == constituency_name].iloc[0]\n", - " \n", - "# percentiles = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 91, 92, 93, 94, 95, 96, 97, 98, 100]\n", - "# income_values = [\n", - "# 0,\n", - "# constituency_data['10 percentile'],\n", - "# constituency_data['20 percentile'],\n", - "# constituency_data['30 percentile'],\n", - "# constituency_data['40 percentile'],\n", - "# constituency_data['50 percentile'],\n", - "# constituency_data['60 percentile'],\n", - "# constituency_data['70 percentile'],\n", - "# constituency_data['80 percentile'],\n", - "# constituency_data['90 percentile'],\n", - "# constituency_data['91 percentile'],\n", - "# constituency_data['92 percentile'],\n", - "# constituency_data['93 percentile'],\n", - "# constituency_data['94 percentile'],\n", - "# constituency_data['95 percentile'],\n", - "# constituency_data['96 percentile'],\n", - "# constituency_data['97 percentile'],\n", - "# constituency_data['98 percentile'],\n", - "# constituency_data['100 percentile']\n", - "# ]\n", - " \n", - "# valid_data = [(p, v) for p, v in zip(percentiles, income_values) if pd.notna(v)]\n", - "# filtered_percentiles, filtered_income = zip(*valid_data)\n", - " \n", - "# plt.figure(figsize=(8, 6))\n", - "# plt.plot(filtered_percentiles, filtered_income, marker='o')\n", - "# plt.xlabel('Percentiles')\n", - "# plt.ylabel('Income')\n", - "# plt.title(f'Income distribution for {constituency_name}')\n", - "# plt.grid(True)\n", - "# plt.savefig(\"pictures/earning_dist.png\", dpi=300, bbox_inches='tight')\n", - "# plt.close()\n", - "\n", - "# # Plot sample data (Darlington with detailed percentiles)\n", - "# plot_constituency_distribution(income_sample, 'Darlington', detailed=True)\n" - ] - }, { "cell_type": "markdown", "metadata": {}, @@ -1418,9 +1312,9 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Map constituency 2010 to 2024\n", + "### Mapping constituencies from 2010 to 2024\n", "\n", - "PolicyEngine uses HMRC household data which aligns with 2010 constituency boundaries; to handle this issue and align it with 2024 constituency boundaries definitions, we follow these processes:\n", + "PolicyEngine uses HMRC income data which aligns with 2010 constituency boundaries; to handle this issue and align it with 2024 constituency boundaries definitions, we follow these processes:\n", "\n", "1. Download the mapping data from the [ONS website](https://www.data.gov.uk/dataset/20c4ffe5-7d86-419f-808e-da98e46f4f52/westminster-pcon-may-2010-to-westminster-pcon-july-2024-lookup-in-the-uk-v2) that contains the official lookup table between 2010 and 2024 Westminster Parliamentary Constituencies.\n", "\n", @@ -1995,23 +1889,23 @@ "\n", "### Loss function\n", "\n", - "The file [`loss.py`](https://github.com/PolicyEngine/policyengine-uk-data/blob/7c782c4839a024c729350a3ff2c76922bf21b0d4/policyengine_uk_data/datasets/frs/local_areas/constituencies/loss.py) defines a function [`create_constituency_target_matrix`](https://github.com/PolicyEngine/policyengine-uk-data/blob/7c782c4839a024c729350a3ff2c76922bf21b0d4/policyengine_uk_data/datasets/frs/local_areas/constituencies/loss.py#L18) that creates target matrices for comparing simulated data against actual constituency-level data. \n", + "The file [`loss.py`](https://github.com/PolicyEngine/policyengine-uk-data/blob/7c782c4839a024c729350a3ff2c76922bf21b0d4/policyengine_uk_data/datasets/frs/local_areas/constituencies/loss.py) defines a function [`create_constituency_target_matrix`](https://github.com/PolicyEngine/policyengine-uk-data/blob/7c782c4839a024c729350a3ff2c76922bf21b0d4/policyengine_uk_data/datasets/frs/local_areas/constituencies/loss.py#L18) that creates target matrices for comparing simulated data against actual constituency-level data. The following process outlines how the function processes:\n", "\n", - "1. The function takes three main input parameters: dataset (defaults to [`enhanced_frs_2022_23`](https://github.com/PolicyEngine/policyengine-uk-data/blob/7c782c4839a024c729350a3ff2c76922bf21b0d4/policyengine_uk_data/datasets/frs/local_areas/constituencies/loss.py#L19)), time_period (defaults to 2025), and an optional reform parameter for policy changes.\n", + "1. Takes three main input parameters: dataset (defaults to [`enhanced_frs_2022_23`](https://github.com/PolicyEngine/policyengine-uk-data/blob/7c782c4839a024c729350a3ff2c76922bf21b0d4/policyengine_uk_data/datasets/frs/local_areas/constituencies/loss.py#L19)), time_period (defaults to 2025), and an optional reform parameter for policy changes.\n", "\n", - "2. It reads three files containing real data: [`age.csv`](https://github.com/PolicyEngine/policyengine-uk-data/blob/7c782c4839a024c729350a3ff2c76922bf21b0d4/policyengine_uk_data/datasets/frs/local_areas/constituencies/targets/age.csv), [`total_income.csv`](https://github.com/PolicyEngine/policyengine-uk-data/blob/7c782c4839a024c729350a3ff2c76922bf21b0d4/policyengine_uk_data/datasets/frs/local_areas/constituencies/targets/total_income.csv), and [`employment_income.csv`](https://github.com/PolicyEngine/policyengine-uk-data/blob/7c782c4839a024c729350a3ff2c76922bf21b0d4/policyengine_uk_data/datasets/frs/local_areas/constituencies/targets/employment_income.csv).\n", + "2. Reads three files containing real data: [`age.csv`](https://github.com/PolicyEngine/policyengine-uk-data/blob/7c782c4839a024c729350a3ff2c76922bf21b0d4/policyengine_uk_data/datasets/frs/local_areas/constituencies/targets/age.csv), [`total_income.csv`](https://github.com/PolicyEngine/policyengine-uk-data/blob/7c782c4839a024c729350a3ff2c76922bf21b0d4/policyengine_uk_data/datasets/frs/local_areas/constituencies/targets/total_income.csv), and [`employment_income.csv`](https://github.com/PolicyEngine/policyengine-uk-data/blob/7c782c4839a024c729350a3ff2c76922bf21b0d4/policyengine_uk_data/datasets/frs/local_areas/constituencies/targets/employment_income.csv).\n", "\n", - "3. It creates a PolicyEngine Microsimulation object using the specified dataset and reform parameters.\n", + "3. Creates a PolicyEngine Microsimulation object using the specified dataset and reform parameters.\n", "\n", - "4. The function creates two main matrices: [`matrix`](https://github.com/PolicyEngine/policyengine-uk-data/blob/7c782c4839a024c729350a3ff2c76922bf21b0d4/policyengine_uk_data/datasets/frs/local_areas/constituencies/loss.py#L33) for simulated values from PolicyEngine, and [`y`](https://github.com/PolicyEngine/policyengine-uk-data/blob/7c782c4839a024c729350a3ff2c76922bf21b0d4/policyengine_uk_data/datasets/frs/local_areas/constituencies/loss.py#L34) for actual target values from both HMRC (income data) and ONS (age data).\n", + "4. Creates two main matrices: [`matrix`](https://github.com/PolicyEngine/policyengine-uk-data/blob/7c782c4839a024c729350a3ff2c76922bf21b0d4/policyengine_uk_data/datasets/frs/local_areas/constituencies/loss.py#L33) for simulated values from PolicyEngine, and [`y`](https://github.com/PolicyEngine/policyengine-uk-data/blob/7c782c4839a024c729350a3ff2c76922bf21b0d4/policyengine_uk_data/datasets/frs/local_areas/constituencies/loss.py#L34) for actual target values from both HMRC (income data) and ONS (age data).\n", "\n", - "5. It calculates total income metrics at the national level, computing both total amounts and counts of people with income.\n", + "5. Calculates total income metrics at the national level, computing both total amounts and counts of people with income.\n", "\n", - "6. It processes age distributions by creating 10-year age bands from 0 to 80, calculating how many people fall into each band.\n", + "6. Processes age distributions by creating 10-year age bands from 0 to 80, calculating how many people fall into each band.\n", "\n", - "7. For employment income, it processes both counts and amounts for different income bands between £12,570 and £70,000, excluding people under 16.\n", + "7. Processes both counts and amounts for different income bands between £12,570 and £70,000, excluding people under 16 for employment income.\n", "\n", - "8. The [`sim.map_result()`](https://github.com/PolicyEngine/policyengine-uk-data/blob/7c782c4839a024c729350a3ff2c76922bf21b0d4/policyengine_uk_data/datasets/frs/local_areas/constituencies/loss.py#L88) function is used throughout to map individual-level results to household level.\n", + "8. Maps individual-level results to household level throughout the [`sim.map_result()`](https://github.com/PolicyEngine/policyengine-uk-data/blob/7c782c4839a024c729350a3ff2c76922bf21b0d4/policyengine_uk_data/datasets/frs/local_areas/constituencies/loss.py#L88) function.\n", "\n", "9. The function returns both the simulated matrix and the target matrix [`(matrix, y)`](https://github.com/PolicyEngine/policyengine-uk-data/blob/7c782c4839a024c729350a3ff2c76922bf21b0d4/policyengine_uk_data/datasets/frs/local_areas/constituencies/loss.py#L34) which can be used for comparing the simulation results against actual data." ] @@ -2165,7 +2059,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 10, "metadata": {}, "outputs": [ { @@ -2180,43 +2074,3595 @@ }, "metadata": {}, "output_type": "display_data" + }, + { + "data": { + "application/vnd.plotly.v1+json": { + "config": { + "plotlyServerURL": "https://plot.ly" + }, + "data": [ + { + "hovertemplate": "%{hovertext}

x=%{x}
y=%{y}
Value=%{marker.color}", + "hovertext": [ + "Aldershot", + "Aldridge-Brownhills", + "Altrincham and Sale West", + "Amber Valley", + "Arundel and South Downs", + "Ashfield", + "Ashford", + "Ashton-under-Lyne", + "Aylesbury", + "Banbury", + "Barking", + "Barnsley North", + "Barnsley South", + "Barrow and Furness", + "Basildon and Billericay", + "Basingstoke", + "Bassetlaw", + "Bath", + "Battersea", + "Beaconsfield", + "Beckenham and Penge", + "Bedford", + "Bermondsey and Old Southwark", + "Bethnal Green and Stepney", + "Beverley and Holderness", + "Bexhill and Battle", + "Bexleyheath and Crayford", + "Bicester and Woodstock", + "Birkenhead", + "Birmingham Edgbaston", + "Birmingham Erdington", + "Birmingham Hall Green and Moseley", + "Birmingham Hodge Hill and Solihull North", + "Birmingham Ladywood", + "Birmingham Northfield", + "Birmingham Perry Barr", + "Birmingham Selly Oak", + "Birmingham Yardley", + "Bishop Auckland", + "Blackburn", + "Blackley and Middleton South", + "Blackpool North and Fleetwood", + "Blackpool South", + "Blaydon and Consett", + "Blyth and Ashington", + "Bognor Regis and Littlehampton", + "Bolsover", + "Bolton North East", + "Bolton South and Walkden", + "Bolton West", + "Bootle", + "Boston and Skegness", + "Bournemouth East", + "Bournemouth West", + "Bracknell", + "Bradford East", + "Bradford South", + "Bradford West", + "Braintree", + "Brent East", + "Brent West", + "Brentford and Isleworth", + "Brentwood and Ongar", + "Bridgwater", + "Bridlington and The Wolds", + "Brigg and Immingham", + "Brighton Kemptown and Peacehaven", + "Brighton Pavilion", + "Bristol Central", + "Bristol East", + "Bristol North East", + "Bristol North West", + "Bristol South", + "Broadland and Fakenham", + "Bromley and Biggin Hill", + "Bromsgrove", + "Broxbourne", + "Broxtowe", + "Buckingham and Bletchley", + "Burnley", + "Burton and Uttoxeter", + "Bury North", + "Bury South", + "Bury St Edmunds and Stowmarket", + "Calder Valley", + "Camborne and Redruth", + "Cambridge", + "Cannock Chase", + "Canterbury", + "Carlisle", + "Carshalton and Wallington", + "Castle Point", + "Central Devon", + "Central Suffolk and North Ipswich", + "Chatham and Aylesford", + "Cheadle", + "Chelmsford", + "Chelsea and Fulham", + "Cheltenham", + "Chesham and Amersham", + "Chester North and Neston", + "Chester South and Eddisbury", + "Chesterfield", + "Chichester", + "Chingford and Woodford Green", + "Chippenham", + "Chipping Barnet", + "Chorley", + "Christchurch", + "Cities of London and Westminster", + "City of Durham", + "Clacton", + "Clapham and Brixton Hill", + "Colchester", + "Colne Valley", + "Congleton", + "Corby and East Northamptonshire", + "Coventry East", + "Coventry North West", + "Coventry South", + "Cramlington and Killingworth", + "Crawley", + "Crewe and Nantwich", + "Croydon East", + "Croydon South", + "Croydon West", + "Dagenham and Rainham", + "Darlington", + "Dartford", + "Daventry", + "Derby North", + "Derby South", + "Derbyshire Dales", + "Dewsbury and Batley", + "Didcot and Wantage", + "Doncaster Central", + "Doncaster East and the Isle of Axholme", + "Doncaster North", + "Dorking and Horley", + "Dover and Deal", + "Droitwich and Evesham", + "Dudley", + "Dulwich and West Norwood", + "Dunstable and Leighton Buzzard", + "Ealing Central and Acton", + "Ealing North", + "Ealing Southall", + "Earley and Woodley", + "Easington", + "East Grinstead and Uckfield", + "East Ham", + "East Hampshire", + "East Surrey", + "East Thanet", + "East Wiltshire", + "East Worthing and Shoreham", + "Eastbourne", + "Eastleigh", + "Edmonton and Winchmore Hill", + "Ellesmere Port and Bromborough", + "Eltham and Chislehurst", + "Ely and East Cambridgeshire", + "Enfield North", + "Epping Forest", + "Epsom and Ewell", + "Erewash", + "Erith and Thamesmead", + "Esher and Walton", + "Exeter", + "Exmouth and Exeter East", + "Fareham and Waterlooville", + "Farnham and Bordon", + "Faversham and Mid Kent", + "Feltham and Heston", + "Filton and Bradley Stoke", + "Finchley and Golders Green", + "Folkestone and Hythe", + "Forest of Dean", + "Frome and East Somerset", + "Fylde", + "Gainsborough", + "Gateshead Central and Whickham", + "Gedling", + "Gillingham and Rainham", + "Glastonbury and Somerton", + "Gloucester", + "Godalming and Ash", + "Goole and Pocklington", + "Gorton and Denton", + "Gosport", + "Grantham and Bourne", + "Gravesham", + "Great Grimsby and Cleethorpes", + "Great Yarmouth", + "Greenwich and Woolwich", + "Guildford", + "Hackney North and Stoke Newington", + "Hackney South and Shoreditch", + "Halesowen", + "Halifax", + "Hamble Valley", + "Hammersmith and Chiswick", + "Hampstead and Highgate", + "Harborough, Oadby and Wigston", + "Harlow", + "Harpenden and Berkhamsted", + "Harrogate and Knaresborough", + "Harrow East", + "Harrow West", + "Hartlepool", + "Harwich and North Essex", + "Hastings and Rye", + "Havant", + "Hayes and Harlington", + "Hazel Grove", + "Hemel Hempstead", + "Hendon", + "Henley and Thame", + "Hereford and South Herefordshire", + "Herne Bay and Sandwich", + "Hertford and Stortford", + "Hertsmere", + "Hexham", + "Heywood and Middleton North", + "High Peak", + "Hinckley and Bosworth", + "Hitchin", + "Holborn and St Pancras", + "Honiton and Sidmouth", + "Hornchurch and Upminster", + "Hornsey and Friern Barnet", + "Horsham", + "Houghton and Sunderland South", + "Hove and Portslade", + "Huddersfield", + "Huntingdon", + "Hyndburn", + "Ilford North", + "Ilford South", + "Ipswich", + "Isle of Wight East", + "Isle of Wight West", + "Islington North", + "Islington South and Finsbury", + "Jarrow and Gateshead East", + "Keighley and Ilkley", + "Kenilworth and Southam", + "Kensington and Bayswater", + "Kettering", + "Kingston and Surbiton", + "Kingston upon Hull East", + "Kingston upon Hull North and Cottingham", + "Kingston upon Hull West and Haltemprice", + "Kingswinford and South Staffordshire", + "Knowsley", + "Lancaster and Wyre", + "Leeds Central and Headingley", + "Leeds East", + "Leeds North East", + "Leeds North West", + "Leeds South", + "Leeds South West and Morley", + "Leeds West and Pudsey", + "Leicester East", + "Leicester South", + "Leicester West", + "Leigh and Atherton", + "Lewes", + "Lewisham East", + "Lewisham North", + "Lewisham West and East Dulwich", + "Leyton and Wanstead", + "Lichfield", + "Lincoln", + "Liverpool Garston", + "Liverpool Riverside", + "Liverpool Walton", + "Liverpool Wavertree", + "Liverpool West Derby", + "Loughborough", + "Louth and Horncastle", + "Lowestoft", + "Luton North", + "Luton South and South Bedfordshire", + "Macclesfield", + "Maidenhead", + "Maidstone and Malling", + "Makerfield", + "Maldon", + "Manchester Central", + "Manchester Rusholme", + "Manchester Withington", + "Mansfield", + "Melksham and Devizes", + "Melton and Syston", + "Meriden and Solihull East", + "Mid Bedfordshire", + "Mid Buckinghamshire", + "Mid Cheshire", + "Mid Derbyshire", + "Mid Dorset and North Poole", + "Mid Leicestershire", + "Mid Norfolk", + "Mid Sussex", + "Middlesbrough and Thornaby East", + "Middlesbrough South and East Cleveland", + "Milton Keynes Central", + "Milton Keynes North", + "Mitcham and Morden", + "Morecambe and Lunesdale", + "New Forest East", + "New Forest West", + "Newark", + "Newbury", + "Newcastle upon Tyne Central and West", + "Newcastle upon Tyne East and Wallsend", + "Newcastle upon Tyne North", + "Newcastle-under-Lyme", + "Newton Abbot", + "Newton Aycliffe and Spennymoor", + "Normanton and Hemsworth", + "North Bedfordshire", + "North Cornwall", + "North Cotswolds", + "North Devon", + "North Dorset", + "North Durham", + "North East Cambridgeshire", + "North East Derbyshire", + "North East Hampshire", + "North East Hertfordshire", + "North East Somerset and Hanham", + "North Herefordshire", + "North Norfolk", + "North Northumberland", + "North Shropshire", + "North Somerset", + "North Warwickshire and Bedworth", + "North West Cambridgeshire", + "North West Essex", + "North West Hampshire", + "North West Leicestershire", + "North West Norfolk", + "Northampton North", + "Northampton South", + "Norwich North", + "Norwich South", + "Nottingham East", + "Nottingham North and Kimberley", + "Nottingham South", + "Nuneaton", + "Old Bexley and Sidcup", + "Oldham East and Saddleworth", + "Oldham West, Chadderton and Royton", + "Orpington", + "Ossett and Denby Dale", + "Oxford East", + "Oxford West and Abingdon", + "Peckham", + "Pendle and Clitheroe", + "Penistone and Stocksbridge", + "Penrith and Solway", + "Peterborough", + "Plymouth Moor View", + "Plymouth Sutton and Devonport", + "Pontefract, Castleford and Knottingley", + "Poole", + "Poplar and Limehouse", + "Portsmouth North", + "Portsmouth South", + "Preston", + "Putney", + "Queen's Park and Maida Vale", + "Rawmarsh and Conisbrough", + "Rayleigh and Wickford", + "Reading Central", + "Reading West and Mid Berkshire", + "Redcar", + "Redditch", + "Reigate", + "Ribble Valley", + "Richmond and Northallerton", + "Richmond Park", + "Rochdale", + "Rochester and Strood", + "Romford", + "Romsey and Southampton North", + "Rossendale and Darwen", + "Rother Valley", + "Rotherham", + "Rugby", + "Ruislip, Northwood and Pinner", + "Runcorn and Helsby", + "Runnymede and Weybridge", + "Rushcliffe", + "Rutland and Stamford", + "Salford", + "Salisbury", + "Scarborough and Whitby", + "Scunthorpe", + "Sefton Central", + "Selby", + "Sevenoaks", + "Sheffield Brightside and Hillsborough", + "Sheffield Central", + "Sheffield Hallam", + "Sheffield Heeley", + "Sheffield South East", + "Sherwood Forest", + "Shipley", + "Shrewsbury", + "Sittingbourne and Sheppey", + "Skipton and Ripon", + "Sleaford and North Hykeham", + "Slough", + "Smethwick", + "Solihull West and Shirley", + "South Basildon and East Thurrock", + "South Cambridgeshire", + "South Cotswolds", + "South Derbyshire", + "South Devon", + "South Dorset", + "South East Cornwall", + "South Holland and The Deepings", + "South Leicestershire", + "South Norfolk", + "South Northamptonshire", + "South Ribble", + "South Shields", + "South Shropshire", + "South Suffolk", + "South West Devon", + "South West Hertfordshire", + "South West Norfolk", + "South West Wiltshire", + "Southampton Itchen", + "Southampton Test", + "Southend East and Rochford", + "Southend West and Leigh", + "Southgate and Wood Green", + "Southport", + "Spelthorne", + "Spen Valley", + "St Albans", + "St Austell and Newquay", + "St Helens North", + "St Helens South and Whiston", + "St Ives", + "St Neots and Mid Cambridgeshire", + "Stafford", + "Staffordshire Moorlands", + "Stalybridge and Hyde", + "Stevenage", + "Stockport", + "Stockton North", + "Stockton West", + "Stoke-on-Trent Central", + "Stoke-on-Trent North", + "Stoke-on-Trent South", + "Stone, Great Wyrley and Penkridge", + "Stourbridge", + "Stratford and Bow", + "Stratford-on-Avon", + "Streatham and Croydon North", + "Stretford and Urmston", + "Stroud", + "Suffolk Coastal", + "Sunderland Central", + "Surrey Heath", + "Sussex Weald", + "Sutton and Cheam", + "Sutton Coldfield", + "Swindon North", + "Swindon South", + "Tamworth", + "Tatton", + "Taunton and Wellington", + "Telford", + "Tewkesbury", + "The Wrekin", + "Thirsk and Malton", + "Thornbury and Yate", + "Thurrock", + "Tipton and Wednesbury", + "Tiverton and Minehead", + "Tonbridge", + "Tooting", + "Torbay", + "Torridge and Tavistock", + "Tottenham", + "Truro and Falmouth", + "Tunbridge Wells", + "Twickenham", + "Tynemouth", + "Uxbridge and South Ruislip", + "Vauxhall and Camberwell Green", + "Wakefield and Rothwell", + "Wallasey", + "Walsall and Bloxwich", + "Walthamstow", + "Warrington North", + "Warrington South", + "Warwick and Leamington", + "Washington and Gateshead South", + "Watford", + "Waveney Valley", + "Weald of Kent", + "Wellingborough and Rushden", + "Wells and Mendip Hills", + "Welwyn Hatfield", + "West Bromwich", + "West Dorset", + "West Ham and Beckton", + "West Lancashire", + "West Suffolk", + "West Worcestershire", + "Westmorland and Lonsdale", + "Weston-super-Mare", + "Wetherby and Easingwold", + "Whitehaven and Workington", + "Widnes and Halewood", + "Wigan", + "Wimbledon", + "Winchester", + "Windsor", + "Wirral West", + "Witham", + "Witney", + "Woking", + "Wokingham", + "Wolverhampton North East", + "Wolverhampton South East", + "Wolverhampton West", + "Worcester", + "Worsley and Eccles", + "Worthing West", + "Wycombe", + "Wyre Forest", + "Wythenshawe and Sale East", + "Yeovil", + "York Central", + "York Outer", + "Belfast East", + "Belfast North", + "Belfast South and Mid Down", + "Belfast West", + "East Antrim", + "East Londonderry", + "Fermanagh and South Tyrone", + "Foyle", + "Lagan Valley", + "Mid Ulster", + "Newry and Armagh", + "North Antrim", + "North Down", + "South Antrim", + "South Down", + "Strangford", + "Upper Bann", + "West Tyrone", + "East Renfrewshire", + "Na h-Eileanan an Iar", + "Midlothian", + "North Ayrshire and Arran", + "Orkney and Shetland", + "Aberdeen North", + "Aberdeen South", + "Aberdeenshire North and Moray East", + "Airdrie and Shotts", + "Alloa and Grangemouth", + "Angus and Perthshire Glens", + "Arbroath and Broughty Ferry", + "Argyll, Bute and South Lochaber", + "Bathgate and Linlithgow", + "Caithness, Sutherland and Easter Ross", + "Coatbridge and Bellshill", + "Cowdenbeath and Kirkcaldy", + "Cumbernauld and Kirkintilloch", + "Dumfries and Galloway", + "Dumfriesshire, Clydesdale and Tweeddale", + "Dundee Central", + "Dunfermline and Dollar", + "East Kilbride and Strathaven", + "Edinburgh East and Musselburgh", + "Edinburgh North and Leith", + "Edinburgh South", + "Edinburgh South West", + "Edinburgh West", + "Falkirk", + "Glasgow East", + "Glasgow North", + "Glasgow North East", + "Glasgow South", + "Glasgow South West", + "Glasgow West", + "Glenrothes and Mid Fife", + "Gordon and Buchan", + "Hamilton and Clyde Valley", + "Inverclyde and Renfrewshire West", + "Inverness, Skye and West Ross-shire", + "Livingston", + "Lothian East", + "Mid Dunbartonshire", + "Moray West, Nairn and Strathspey", + "Motherwell, Wishaw and Carluke", + "North East Fife", + "Paisley and Renfrewshire North", + "Paisley and Renfrewshire South", + "Perth and Kinross-shire", + "Rutherglen", + "Stirling and Strathallan", + "West Dunbartonshire", + "Ayr, Carrick and Cumnock", + "Berwickshire, Roxburgh and Selkirk", + "Central Ayrshire", + "Kilmarnock and Loudoun", + "West Aberdeenshire and Kincardine", + "Aberafan Maesteg", + "Alyn and Deeside", + "Bangor Aberconwy", + "Blaenau Gwent and Rhymney", + "Brecon, Radnor and Cwm Tawe", + "Bridgend", + "Caerfyrddin", + "Caerphilly", + "Cardiff East", + "Cardiff North", + "Cardiff South and Penarth", + "Cardiff West", + "Ceredigion Preseli", + "Clwyd East", + "Clwyd North", + "Dwyfor Meirionnydd", + "Gower", + "Llanelli", + "Merthyr Tydfil and Aberdare", + "Mid and South Pembrokeshire", + "Monmouthshire", + "Montgomeryshire and Glyndwr", + "Neath and Swansea East", + "Newport East", + "Newport West and Islwyn", + "Pontypridd", + "Rhondda and Ogmore", + "Swansea West", + "Torfaen", + "Vale of Glamorgan", + "Wrexham", + "Ynys Môn" + ], + "legendgroup": "", + "marker": { + "color": [ + 41423.47265625, + 34819.73046875, + 50368.54296875, + 35540.13653859061, + 38036.82334936957, + 33378.91015625, + 38001.53515625, + 34819.73046875, + 40823.1328125, + 43764.80078125, + 34519.5625, + 34519.5625, + 34519.5625, + 35420.0703125, + 40703.06640625, + 40823.1328125, + 36980.95703125, + 40823.1328125, + 60454.25390625, + 49948.3046875, + 47546.93792127848, + 44185.0390625, + 48807.65625, + 52109.52734375, + 36860.88671875, + 35420.0703125, + 41843.7109375, + 44004.938457836084, + 38001.53515625, + 38341.571060303155, + 33378.9140625, + 34519.5625, + 36860.88671875, + 34819.73046875, + 35239.96875, + 35720.2421875, + 34519.5625, + 34519.5625, + 34819.73046875, + 34579.59375, + 34519.5625, + 38421.7734375, + 33979.25390625, + 35420.0703125, + 35420.0703125, + 37060.44420507146, + 34519.55859375, + 35420.0703125, + 36860.88671875, + 35420.0703125, + 33138.77734375, + 35420.0703125, + 35239.96875, + 36020.41015625, + 44185.0390625, + 32838.609375, + 33378.9140625, + 32288.342418136006, + 44905.4453125, + 47366.83984375, + 40042.69140625, + 40823.1328125, + 50848.8125, + 34579.59375, + 35420.0703125, + 37101.0234375, + 38661.91015625, + 40042.69140625, + 39142.1796875, + 38327.67502989451, + 38001.53125, + 39142.1796875, + 37281.125, + 40042.69140625, + 49407.9921875, + 41423.47265625, + 44185.0390625, + 34579.59375, + 41843.7109375, + 32418.369140625, + 34579.59375, + 37281.125, + 35239.96875, + 37281.125, + 40703.06640625, + 35420.0703125, + 42083.84375, + 34519.5625, + 39142.1796875, + 34579.59375, + 42984.359375, + 39742.51953125, + 35540.136438683, + 39742.51953125, + 39322.28125, + 43524.662664472926, + 44125, + 58052.89453125, + 40703.06640625, + 44185.0390625, + 38421.7734375, + 39142.1796875, + 33559.015625, + 35900.33984375, + 45265.6484375, + 39022.11328125, + 50428.57421875, + 35900.33984375, + 37281.125, + 57392.515625, + 34819.73046875, + 36860.890625, + 51809.359375, + 37641.328125, + 35720.2421875, + 42984.359375, + 35420.0703125, + 33138.77734375, + 35420.0703125, + 33138.77734375, + 36860.890625, + 39142.1796875, + 38001.53125, + 43524.66105736767, + 43524.66105736767, + 40703.06640625, + 39142.1796875, + 35720.2421875, + 40703.06640625, + 38661.91015625, + 34579.59375, + 35420.0703125, + 39742.51953125, + 35239.96875, + 43524.661389119305, + 34519.5625, + 35720.2421875, + 34579.59375, + 44185.0390625, + 36020.40625, + 36020.41015625, + 34819.73046875, + 47967.1796875, + 36980.95703125, + 48027.21484375, + 38421.7734375, + 43824.83203125, + 43644.73046875, + 35720.2421875, + 42624.15234375, + 35420.0703125, + 44185.0390625, + 46706.46484375, + 36620.75, + 39742.51953125, + 38001.53515625, + 36980.95703125, + 41003.23046875, + 42624.15234375, + 38421.7734375, + 43524.66267877325, + 40703.06640625, + 42624.15234375, + 50308.50390625, + 44185.0390625, + 35420.0703125, + 43524.6640625, + 50608.67578125, + 36020.41015625, + 36980.95703125, + 40703.06640625, + 45265.6484375, + 38001.53515625, + 34819.73046875, + 39322.28125, + 52049.4921875, + 38421.7734375, + 38421.7734375, + 37641.328125, + 40703.06640625, + 38001.53515625, + 34819.73046875, + 35420.0703125, + 39742.51953125, + 37281.125, + 34579.59375, + 44185.0390625, + 37281.125, + 37281.125, + 38421.7734375, + 35720.2421875, + 36860.88671875, + 36860.890625, + 34579.59375, + 51329.08203125, + 41423.47265625, + 50283.6779735496, + 50283.6779735496, + 35420.0703125, + 35420.0703125, + 40042.69140625, + 50848.80859375, + 56792.18359375, + 40282.828125, + 46046.09375, + 45625.85546875, + 40042.69140625, + 41423.47265625, + 40042.69140625, + 35600.171875, + 37641.328125, + 35420.0703125, + 37281.125, + 40703.06640625, + 36020.41015625, + 44785.37890625, + 45085.546875, + 48327.38671875, + 34579.59375, + 37281.125, + 47126.703125, + 41423.47265625, + 38361.73828125, + 34579.59375, + 37641.328125, + 37641.328125, + 44185.0390625, + 57572.6171875, + 35420.0703125, + 44905.4453125, + 50308.50510633398, + 40823.1328125, + 34579.59375, + 40703.06640625, + 35420.0703125, + 38346.81146774556, + 35420.0703125, + 40703.06640625, + 38001.53125, + 35420.0703125, + 33498.984375, + 33498.984375, + 48927.7265625, + 51809.359375, + 34579.59375, + 40703.06640625, + 41843.7109375, + 60994.5703125, + 35420.0703125, + 52529.765625, + 33138.77734375, + 34519.5625, + 35720.2421875, + 37281.125, + 35420.0703125, + 38001.53125, + 35239.96875, + 35420.0703125, + 35720.2421875, + 40042.69140625, + 35239.96875, + 35420.0703125, + 35720.2421875, + 32118.19921875, + 33378.9140625, + 34339.45703125, + 35600.171875, + 39322.28125, + 44185.0390625, + 42804.25390625, + 46046.09375, + 43764.80078125, + 38361.73828125, + 33498.984375, + 40042.69140625, + 35420.0703125, + 35720.2421875, + 37641.328125, + 36680.78515625, + 35720.2421875, + 36860.88671875, + 37281.125, + 36680.78515625, + 36980.95703125, + 40703.06640625, + 46046.09375, + 37641.328125, + 35720.2421875, + 41843.7109375, + 34579.59375, + 34519.5625, + 39142.1796875, + 34159.35546875, + 37641.328125, + 37281.125, + 41603.57421875, + 42083.84375, + 41843.7109375, + 42083.84375, + 36860.88671875, + 37281.125, + 37281.125, + 35420.0703125, + 41543.54296875, + 35420.0703125, + 33679.0859375, + 40703.06640625, + 40703.06640625, + 47186.73828125, + 36680.78515625, + 38421.7734375, + 40643.0234375, + 39742.51953125, + 44125, + 36860.890625, + 34519.5625, + 36010.911138705706, + 37281.125, + 33559.015625, + 36860.890625, + 34519.5625, + 43764.80078125, + 34519.5625, + 39322.28125, + 37641.328125, + 35600.171875, + 34579.59375, + 36020.41015625, + 34519.55859375, + 42564.12109375, + 44185.0390625, + 36980.95703125, + 34579.59375, + 38001.53125, + 35720.2421875, + 34819.73046875, + 43524.66335780143, + 37281.125, + 36020.41015625, + 53490.3125, + 43213.00735171613, + 39022.11328125, + 34579.59375, + 35239.96875, + 39142.1796875, + 37281.125, + 37281.125, + 33378.91015625, + 34579.59375, + 33378.9140625, + 36680.78515625, + 46046.09375, + 36020.41015625, + 34519.5625, + 49708.1640625, + 34579.59375, + 39322.28125, + 40643.0234375, + 48807.65625, + 34579.59375, + 39502.37890625, + 36020.41015625, + 36020.41015625, + 33378.9140625, + 32478.40625, + 34519.5625, + 36020.41015625, + 52049.4921875, + 34819.73046875, + 36860.890625, + 38267.35794199639, + 57752.725900697464, + 51809.359375, + 34819.73046875, + 38001.53515625, + 40823.1328125, + 42624.15234375, + 33559.015625, + 36020.41015625, + 47126.703125, + 37281.125, + 34579.59375, + 59853.91796875, + 35360.0390625, + 40042.69140625, + 44185.0390625, + 43764.80078125, + 34579.59375, + 34579.59375, + 34579.59375, + 40703.06640625, + 45625.85546875, + 38361.73828125, + 50608.67578125, + 43644.73046875, + 37641.328125, + 34579.59375, + 38001.53515625, + 34819.73046875, + 35420.0703125, + 39142.1796875, + 39322.28125, + 42624.15234375, + 34579.59375, + 37581.296875, + 39742.51953125, + 39742.51953125, + 35900.34375, + 38303.52042788706, + 40703.06640625, + 37281.125, + 34819.73046875, + 40042.69140625, + 35420.0703125, + 36860.890625, + 34519.5625, + 41603.57421875, + 39322.28125, + 42984.359375, + 40042.69140625, + 39322.28125, + 35420.0703125, + 37821.43359375, + 36860.88671875, + 34819.73046875, + 39502.37890625, + 35420.0703125, + 38661.91015625, + 38001.53125, + 34579.59375, + 36860.88671875, + 40042.69140625, + 38308.95661417534, + 45085.546875, + 34579.59375, + 37281.125, + 34579.59375, + 34519.5625, + 39562.4140625, + 38001.53125, + 44185.0390625, + 38361.73828125, + 43464.62890625, + 35239.96875, + 55291.33203125, + 34579.59375, + 34819.73046875, + 35420.0703125, + 34819.73046875, + 40703.06640625, + 39562.41796875, + 40703.06640625, + 34639.62890625, + 39142.1796875, + 34519.5625, + 36620.75, + 36860.890625, + 35239.96875, + 36860.890625, + 37281.125, + 40042.69140625, + 34819.73046875, + 50288.55778180683, + 44185.0390625, + 41423.47265625, + 36860.890625, + 40042.69140625, + 37040.984375, + 33559.015625, + 45926.0234375, + 40282.828125, + 42984.359375, + 43644.73046875, + 39022.11328125, + 39022.11328125, + 38361.73828125, + 41423.47265625, + 35600.171875, + 35420.0703125, + 38001.53125, + 36620.75, + 34579.59375, + 39322.28125, + 38421.7734375, + 34579.59375, + 35239.96875, + 40703.06640625, + 49708.1640625, + 34519.5625, + 38001.53515625, + 48327.38671875, + 34579.59375, + 47366.83984375, + 42564.12109375, + 35900.34765625, + 44185.0390625, + 51809.359375, + 37281.125, + 34579.59375, + 34519.5625, + 46706.46484375, + 40042.69140625, + 40042.69140625, + 44125, + 35239.96875, + 40703.06640625, + 39022.11328125, + 39322.28125, + 34579.59375, + 36860.890625, + 43644.73046875, + 36020.41015625, + 35420.0703125, + 39322.28125, + 35720.2421875, + 38001.53125, + 40042.69140625, + 38001.53515625, + 34579.59375, + 37281.125, + 39022.11328125, + 36860.88671875, + 34819.73046875, + 51809.359375, + 42984.359375, + 42984.359375, + 36860.890625, + 40823.1328125, + 42624.15234375, + 45745.91796875, + 44305.10546875, + 34519.5625, + 33498.984375, + 34819.73046875, + 34819.73046875, + 35720.2421875, + 40042.69140625, + 40703.06640625, + 36020.41015625, + 35420.0703125, + 37941.5, + 36860.88671875, + 36860.88671875, + 35420.0703125, + 34519.5625, + 36020.41015625, + 35900.34375, + 35420.0703125, + 34819.73046875, + 36860.88671875, + 35720.2421875, + 36860.88671875, + 36860.88671875, + 34819.73046875, + 36860.88671875, + 36860.88671875, + 35420.0703125, + 36860.88671875, + 34579.59375, + 36860.890625, + 36860.88671875, + 43644.73046875, + 40042.69140625, + 39742.51953125, + 35420.0703125, + 42564.12109375, + 39742.51953125, + 38421.7734375, + 35239.96875, + 38001.53125, + 39142.1796875, + 36860.88671875, + 34579.59375, + 36860.88671875, + 39322.28125, + 38001.53515625, + 38001.53125, + 36860.88671875, + 39322.28125, + 34579.59375, + 36860.88671875, + 34579.59375, + 38305.303871994074, + 40042.69140625, + 39322.28125, + 41543.54296875, + 41423.47265625, + 44905.4453125, + 41543.54296875, + 37941.5, + 38421.7734375, + 40282.828125, + 39322.28125, + 40643.0234375, + 38349.69803445856, + 40943.20044377309, + 35420.0703125, + 39022.11328125, + 40042.69140625, + 36080.4453125, + 37281.125, + 39322.28125, + 40282.828125, + 40703.06640625, + 37581.296875, + 38361.73828125, + 34879.765625, + 35900.34765625, + 37101.0234375, + 40042.69140625, + 40042.69140625, + 40042.69140625, + 38001.53125, + 38001.53515625, + 34519.5625, + 40462.9375, + 34519.5625, + 44185.0390625, + 36620.75, + 38001.53125, + 38001.53125, + 35420.0703125, + 34519.5625, + 35900.34375, + 39742.51953125, + 36860.88671875, + 35420.0703125, + 38361.73828125, + 35720.2421875, + 36680.78515625, + 38902.0390625, + 36860.890625, + 36260.546875, + 37521.2578125, + 39322.28125, + 40282.828125, + 34519.5625, + 38121.6015625, + 34519.5625, + 36980.95703125, + 37040.98828125, + 34519.5625, + 39022.109375, + 35360.0390625, + 35420.0703125, + 39742.51953125, + 36860.890625, + 36860.88671875, + 35720.2421875, + 36860.88671875 + ], + "coloraxis": "coloraxis", + "line": { + "color": "lightgray", + "width": 0 + }, + "size": 10, + "symbol": "hexagon" + }, + "mode": "markers", + "name": "", + "orientation": "v", + "showlegend": false, + "type": "scatter", + "x": [ + 55.5, + 55.5, + 52, + 58, + 60.5, + 60, + 71.5, + 54, + 60, + 58, + 67.5, + 57, + 58, + 53.5, + 66.5, + 55, + 60.5, + 50.5, + 62, + 57, + 65, + 62.5, + 63.5, + 65, + 63.5, + 69.5, + 67, + 58.5, + 49, + 53, + 54, + 54.5, + 55, + 53.5, + 53.5, + 53, + 54, + 55.5, + 53.5, + 53, + 53, + 52.5, + 51.5, + 54.5, + 54.5, + 62.5, + 59.5, + 52, + 51.5, + 51, + 48.5, + 63.5, + 52, + 51.5, + 56, + 57.5, + 56, + 56.5, + 67, + 60.5, + 59.5, + 59.5, + 66, + 48, + 62.5, + 61.5, + 67, + 66.5, + 50.5, + 51.5, + 51, + 49.5, + 51, + 66, + 66.5, + 52, + 66, + 59, + 59.5, + 55, + 55.5, + 53, + 52.5, + 68, + 55.5, + 43, + 64.5, + 54, + 71, + 52.5, + 62, + 68.5, + 46.5, + 68, + 68.5, + 54.5, + 67, + 60.5, + 51.5, + 58.5, + 49.5, + 51, + 58.5, + 59.5, + 64, + 52, + 61.5, + 52.5, + 52.5, + 62.5, + 54.5, + 68.5, + 61.5, + 67.5, + 55, + 54, + 61.5, + 57, + 56, + 56.5, + 55.5, + 68.5, + 53, + 64.5, + 64, + 63, + 67, + 55, + 67.5, + 59.5, + 57.5, + 56.5, + 56.5, + 56.5, + 53.5, + 60, + 61, + 60.5, + 59, + 72, + 53.5, + 51, + 62.5, + 62, + 59, + 58.5, + 58, + 55.5, + 56.5, + 69, + 66.5, + 55, + 67, + 71, + 53, + 64.5, + 69, + 54, + 63.5, + 50, + 66, + 65.5, + 62, + 67, + 60, + 58.5, + 66.5, + 57.5, + 47.5, + 48, + 55, + 55.5, + 70.5, + 58.5, + 50, + 61, + 70.5, + 50, + 50, + 51, + 61, + 56, + 60.5, + 69.5, + 49, + 51, + 56.5, + 61, + 54.5, + 57, + 62.5, + 68, + 62.5, + 67, + 65.5, + 56, + 63.5, + 64, + 51, + 55, + 56, + 60, + 61.5, + 61, + 66.5, + 61.5, + 58.5, + 60, + 59, + 58.5, + 69, + 70, + 58.5, + 57.5, + 55, + 63.5, + 60.5, + 58, + 50.5, + 71.5, + 65.5, + 65.5, + 53, + 53.5, + 56, + 57.5, + 63.5, + 62, + 49, + 66, + 62.5, + 61.5, + 57, + 65.5, + 55.5, + 63, + 54, + 64.5, + 65, + 67.5, + 54, + 53, + 62.5, + 63, + 56.5, + 56, + 55.5, + 61, + 60.5, + 58.5, + 62.5, + 62, + 61.5, + 51.5, + 50, + 53.5, + 59.5, + 60.5, + 59, + 58, + 59, + 58, + 58.5, + 59.5, + 60, + 59, + 51, + 68, + 65.5, + 64.5, + 65, + 64, + 56, + 62, + 50, + 48.5, + 49, + 49, + 49.5, + 58.5, + 63, + 67.5, + 63, + 62.5, + 55.5, + 56.5, + 69, + 50.5, + 69, + 53.5, + 53, + 53.5, + 61, + 51.5, + 61, + 55, + 61.5, + 59, + 52, + 57, + 50, + 58, + 64.5, + 68, + 57, + 59, + 60.5, + 61, + 61, + 54, + 54, + 53, + 61.5, + 54, + 54, + 55.5, + 55, + 51.5, + 47, + 55.5, + 59, + 62, + 45, + 53, + 46, + 50.5, + 54, + 64, + 57.5, + 55.5, + 64.5, + 50, + 51.5, + 65, + 53.5, + 50, + 49, + 56.5, + 63.5, + 66, + 54, + 58, + 63.5, + 60.5, + 60, + 65.5, + 66, + 60, + 59.5, + 59, + 57, + 67, + 54.5, + 53.5, + 66, + 57.5, + 57.5, + 57, + 64, + 55.5, + 56, + 52, + 63, + 46, + 46.5, + 59.5, + 51, + 66, + 58, + 57.5, + 52, + 61, + 61.5, + 59.5, + 67.5, + 55, + 54.5, + 58, + 53, + 67.5, + 54.5, + 56.5, + 59, + 54, + 69, + 65.5, + 53.5, + 54.5, + 60, + 58.5, + 57.5, + 59.5, + 50.5, + 57, + 61.5, + 62, + 52.5, + 52, + 61, + 60.5, + 49.5, + 60, + 67.5, + 57.5, + 58, + 56.5, + 57, + 59, + 62, + 57, + 50.5, + 70, + 57.5, + 62.5, + 56, + 52.5, + 54.5, + 67.5, + 65, + 52.5, + 57, + 48, + 50.5, + 45.5, + 63, + 58.5, + 67, + 59, + 51.5, + 57.5, + 50, + 68.5, + 47, + 61, + 65, + 51, + 54.5, + 53.5, + 68.5, + 68, + 63, + 50, + 57.5, + 57, + 64.5, + 44.5, + 50, + 49.5, + 42.5, + 64, + 53.5, + 56, + 55.5, + 64, + 54, + 57.5, + 56, + 54.5, + 55, + 55, + 52.5, + 50.5, + 64.5, + 54, + 63.5, + 51.5, + 52, + 69, + 58, + 57, + 69.5, + 59.5, + 56, + 53, + 52.5, + 56.5, + 51.5, + 48.5, + 52, + 52.5, + 51, + 59.5, + 50.5, + 66.5, + 52, + 47, + 68, + 60.5, + 47.5, + 45.5, + 62, + 44, + 68.5, + 58, + 56, + 58, + 63, + 58.5, + 48, + 54.5, + 63, + 51, + 50.5, + 55, + 55, + 65, + 66.5, + 70, + 62.5, + 49.5, + 65, + 51.5, + 49.5, + 65.5, + 49, + 66.5, + 52, + 53, + 48.5, + 61.5, + 52.5, + 50.5, + 50.5, + 60, + 54.5, + 56.5, + 48.5, + 68, + 56, + 56.5, + 54.5, + 53, + 53.5, + 52.5, + 52.5, + 52, + 63.5, + 57.5, + 50, + 52.5, + 49.5, + 60, + 60.5, + 45, + 44.5, + 44.5, + 44, + 45, + 43, + 42, + 42, + 43.5, + 42.5, + 44, + 44, + 45.5, + 43.5, + 45.5, + 46, + 42.5, + 41.5, + 48, + 46.5, + 52, + 47.5, + 50.5, + 52, + 51.5, + 51, + 50, + 50, + 50, + 52, + 49, + 51, + 49.5, + 49.5, + 52, + 49.5, + 51, + 52, + 49.5, + 51, + 48, + 53.5, + 53, + 52.5, + 51.5, + 52, + 50.5, + 50.5, + 49, + 50, + 49, + 49.5, + 48.5, + 51.5, + 49.5, + 50.5, + 47.5, + 49, + 51, + 53, + 49, + 48.5, + 51.5, + 50.5, + 48, + 48.5, + 51, + 48.5, + 48.5, + 48, + 49, + 52.5, + 47.5, + 50, + 50.5, + 45.5, + 49, + 47, + 49, + 49.5, + 46, + 48.5, + 49, + 48, + 47.5, + 47.5, + 47, + 47.5, + 48.5, + 47.5, + 48, + 44, + 44.5, + 48.5, + 43.5, + 49.5, + 49, + 47, + 49, + 48.5, + 48, + 46.5, + 45, + 49.5, + 46.5, + 49.5, + 46 + ], + "xaxis": "x", + "y": [ + -40, + -30, + -25, + -27, + -44, + -27, + -42, + -23, + -35, + -33, + -38, + -23, + -23, + -16, + -34, + -39, + -26, + -40, + -41, + -37, + -43, + -32, + -40, + -39, + -22, + -44, + -39, + -34, + -27, + -33, + -31, + -32, + -31, + -32, + -34, + -31, + -33, + -32, + -14, + -19, + -23, + -18, + -18, + -14, + -12, + -44, + -26, + -21, + -22, + -21, + -22, + -26, + -43, + -42, + -39, + -20, + -21, + -20, + -31, + -38, + -38, + -40, + -33, + -41, + -20, + -24, + -45, + -44, + -38, + -38, + -37, + -38, + -39, + -27, + -42, + -33, + -35, + -27, + -34, + -19, + -28, + -21, + -22, + -31, + -20, + -45, + -30, + -29, + -41, + -14, + -43, + -36, + -42, + -29, + -40, + -26, + -33, + -40, + -36, + -36, + -28, + -27, + -26, + -44, + -35, + -39, + -36, + -20, + -42, + -40, + -16, + -32, + -42, + -32, + -23, + -27, + -30, + -33, + -33, + -34, + -12, + -44, + -27, + -42, + -43, + -43, + -37, + -17, + -40, + -32, + -28, + -28, + -26, + -22, + -38, + -23, + -23, + -22, + -43, + -41, + -36, + -31, + -42, + -33, + -39, + -38, + -39, + -36, + -16, + -43, + -38, + -41, + -43, + -39, + -41, + -44, + -45, + -41, + -36, + -27, + -41, + -30, + -35, + -35, + -43, + -28, + -40, + -42, + -42, + -43, + -43, + -42, + -40, + -40, + -37, + -37, + -42, + -35, + -41, + -19, + -25, + -15, + -28, + -40, + -41, + -35, + -42, + -21, + -24, + -43, + -28, + -39, + -24, + -27, + -40, + -41, + -38, + -39, + -33, + -21, + -43, + -39, + -38, + -31, + -32, + -34, + -18, + -37, + -37, + -16, + -31, + -43, + -44, + -38, + -25, + -34, + -36, + -35, + -34, + -40, + -32, + -34, + -13, + -20, + -25, + -30, + -32, + -39, + -43, + -37, + -36, + -44, + -15, + -44, + -22, + -31, + -19, + -36, + -37, + -30, + -45, + -45, + -38, + -39, + -14, + -19, + -34, + -39, + -30, + -42, + -22, + -21, + -22, + -30, + -23, + -18, + -20, + -20, + -19, + -19, + -21, + -21, + -20, + -30, + -31, + -31, + -25, + -45, + -42, + -40, + -41, + -37, + -29, + -25, + -25, + -24, + -23, + -25, + -24, + -30, + -25, + -28, + -33, + -34, + -26, + -36, + -41, + -22, + -33, + -24, + -25, + -26, + -27, + -40, + -29, + -33, + -32, + -35, + -27, + -27, + -43, + -31, + -28, + -43, + -17, + -17, + -34, + -33, + -43, + -17, + -43, + -43, + -26, + -37, + -13, + -14, + -13, + -28, + -43, + -16, + -23, + -31, + -43, + -37, + -41, + -42, + -15, + -29, + -26, + -38, + -32, + -39, + -34, + -27, + -12, + -29, + -39, + -32, + -30, + -31, + -39, + -29, + -28, + -32, + -33, + -28, + -29, + -29, + -28, + -29, + -31, + -41, + -22, + -22, + -43, + -22, + -34, + -35, + -41, + -18, + -23, + -15, + -29, + -43, + -44, + -22, + -43, + -39, + -43, + -44, + -19, + -41, + -40, + -24, + -34, + -37, + -36, + -17, + -35, + -44, + -18, + -18, + -41, + -21, + -39, + -36, + -40, + -20, + -25, + -24, + -32, + -36, + -28, + -41, + -28, + -29, + -24, + -41, + -19, + -24, + -20, + -21, + -42, + -24, + -25, + -24, + -25, + -25, + -27, + -19, + -30, + -39, + -18, + -26, + -37, + -32, + -34, + -36, + -31, + -38, + -29, + -45, + -44, + -44, + -27, + -32, + -29, + -33, + -20, + -14, + -31, + -30, + -45, + -35, + -29, + -41, + -42, + -42, + -34, + -35, + -35, + -19, + -40, + -21, + -34, + -44, + -21, + -22, + -46, + -31, + -28, + -27, + -24, + -33, + -25, + -16, + -17, + -28, + -27, + -29, + -28, + -32, + -38, + -35, + -42, + -24, + -37, + -29, + -15, + -39, + -42, + -42, + -31, + -39, + -40, + -30, + -26, + -42, + -29, + -36, + -29, + -18, + -36, + -36, + -31, + -41, + -41, + -42, + -44, + -42, + -37, + -45, + -42, + -41, + -13, + -37, + -41, + -22, + -27, + -30, + -37, + -23, + -24, + -35, + -15, + -35, + -28, + -41, + -30, + -40, + -33, + -32, + -44, + -38, + -21, + -30, + -35, + -15, + -40, + -20, + -16, + -26, + -20, + -41, + -40, + -38, + -28, + -33, + -35, + -40, + -38, + -29, + -30, + -30, + -34, + -23, + -44, + -36, + -33, + -26, + -42, + -19, + -18, + -17, + -16, + -18, + -17, + -15, + -15, + -17, + -15, + -18, + -16, + -19, + -15, + -16, + -16, + -18, + -17, + -18, + -16, + -11, + -2, + -11, + -10, + 0, + -3, + -4, + -3, + -11, + -7, + -5, + -5, + -5, + -9, + -2, + -12, + -7, + -8, + -13, + -13, + -6, + -7, + -13, + -10, + -9, + -10, + -10, + -9, + -8, + -10, + -9, + -9, + -11, + -10, + -8, + -6, + -4, + -12, + -8, + -3, + -11, + -11, + -7, + -4, + -12, + -6, + -9, + -10, + -5, + -12, + -6, + -7, + -13, + -12, + -12, + -13, + -4, + -36, + -29, + -31, + -33, + -32, + -37, + -32, + -35, + -37, + -36, + -38, + -37, + -34, + -30, + -30, + -31, + -37, + -36, + -34, + -36, + -36, + -31, + -35, + -37, + -36, + -35, + -36, + -37, + -34, + -38, + -30, + -29 + ], + "yaxis": "y" + } + ], + "layout": { + "annotations": [ + { + "showarrow": false, + "text": "Source: PolicyEngine tax-benefit microsimulation model (version 2.15.1)", + "x": 0, + "xanchor": "left", + "xref": "paper", + "y": -0.15, + "yanchor": "bottom", + "yref": "paper" + } + ], + "coloraxis": { + "cmax": 60994.5703125, + "cmin": 0, + "colorbar": { + "title": { + "text": "Value" + } + }, + "colorscale": [ + [ + 0, + "lightgray" + ], + [ + 1, + "#2C6496" + ] + ] + }, + "font": { + "color": "black", + "family": "Roboto Serif" + }, + "height": 600, + "images": [ + { + "sizex": 0.15, + "sizey": 0.15, + "source": "https://raw.githubusercontent.com/PolicyEngine/policyengine-app/master/src/images/logos/policyengine/blue.png", + "x": 1.1, + "xanchor": "right", + "xref": "paper", + "y": -0.15, + "yanchor": "bottom", + "yref": "paper" + } + ], + "legend": { + "tracegroupgap": 0 + }, + "margin": { + "t": 60 + }, + "modebar": { + "activecolor": "lightgray", + "bgcolor": "lightgray", + "color": "lightgray" + }, + "paper_bgcolor": "lightgray", + "plot_bgcolor": "lightgray", + "template": { + "data": { + "bar": [ + { + "error_x": { + "color": "#2a3f5f" + }, + "error_y": { + "color": "#2a3f5f" + }, + "marker": { + "line": { + "color": "white", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "bar" + } + ], + "barpolar": [ + { + "marker": { + "line": { + "color": "white", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "barpolar" + } + ], + "carpet": [ + { + "aaxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "#C8D4E3", + "linecolor": "#C8D4E3", + "minorgridcolor": "#C8D4E3", + "startlinecolor": "#2a3f5f" + }, + "baxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "#C8D4E3", + "linecolor": "#C8D4E3", + "minorgridcolor": "#C8D4E3", + "startlinecolor": "#2a3f5f" + }, + "type": "carpet" + } + ], + "choropleth": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "choropleth" + } + ], + "contour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "contour" + } + ], + "contourcarpet": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "contourcarpet" + } + ], + "heatmap": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmap" + } + ], + "heatmapgl": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmapgl" + } + ], + "histogram": [ + { + "marker": { + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "histogram" + } + ], + "histogram2d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2d" + } + ], + "histogram2dcontour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2dcontour" + } + ], + "mesh3d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "mesh3d" + } + ], + "parcoords": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "parcoords" + } + ], + "pie": [ + { + "automargin": true, + "type": "pie" + } + ], + "scatter": [ + { + "fillpattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + }, + "type": "scatter" + } + ], + "scatter3d": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatter3d" + } + ], + "scattercarpet": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattercarpet" + } + ], + "scattergeo": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergeo" + } + ], + "scattergl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergl" + } + ], + "scattermapbox": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattermapbox" + } + ], + "scatterpolar": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolar" + } + ], + "scatterpolargl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolargl" + } + ], + "scatterternary": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterternary" + } + ], + "surface": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "surface" + } + ], + "table": [ + { + "cells": { + "fill": { + "color": "#EBF0F8" + }, + "line": { + "color": "white" + } + }, + "header": { + "fill": { + "color": "#C8D4E3" + }, + "line": { + "color": "white" + } + }, + "type": "table" + } + ] + }, + "layout": { + "annotationdefaults": { + "arrowcolor": "#2a3f5f", + "arrowhead": 0, + "arrowwidth": 1 + }, + "autotypenumbers": "strict", + "coloraxis": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "colorscale": { + "diverging": [ + [ + 0, + "#8e0152" + ], + [ + 0.1, + "#c51b7d" + ], + [ + 0.2, + "#de77ae" + ], + [ + 0.3, + "#f1b6da" + ], + [ + 0.4, + "#fde0ef" + ], + [ + 0.5, + "#f7f7f7" + ], + [ + 0.6, + "#e6f5d0" + ], + [ + 0.7, + "#b8e186" + ], + [ + 0.8, + "#7fbc41" + ], + [ + 0.9, + "#4d9221" + ], + [ + 1, + "#276419" + ] + ], + "sequential": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "sequentialminus": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ] + }, + "colorway": [ + "#636efa", + "#EF553B", + "#00cc96", + "#ab63fa", + "#FFA15A", + "#19d3f3", + "#FF6692", + "#B6E880", + "#FF97FF", + "#FECB52" + ], + "font": { + "color": "#2a3f5f" + }, + "geo": { + "bgcolor": "white", + "lakecolor": "white", + "landcolor": "white", + "showlakes": true, + "showland": true, + "subunitcolor": "#C8D4E3" + }, + "hoverlabel": { + "align": "left" + }, + "hovermode": "closest", + "mapbox": { + "style": "light" + }, + "paper_bgcolor": "white", + "plot_bgcolor": "white", + "polar": { + "angularaxis": { + "gridcolor": "#EBF0F8", + "linecolor": "#EBF0F8", + "ticks": "" + }, + "bgcolor": "white", + "radialaxis": { + "gridcolor": "#EBF0F8", + "linecolor": "#EBF0F8", + "ticks": "" + } + }, + "scene": { + "xaxis": { + "backgroundcolor": "white", + "gridcolor": "#DFE8F3", + "gridwidth": 2, + "linecolor": "#EBF0F8", + "showbackground": true, + "ticks": "", + "zerolinecolor": "#EBF0F8" + }, + "yaxis": { + "backgroundcolor": "white", + "gridcolor": "#DFE8F3", + "gridwidth": 2, + "linecolor": "#EBF0F8", + "showbackground": true, + "ticks": "", + "zerolinecolor": "#EBF0F8" + }, + "zaxis": { + "backgroundcolor": "white", + "gridcolor": "#DFE8F3", + "gridwidth": 2, + "linecolor": "#EBF0F8", + "showbackground": true, + "ticks": "", + "zerolinecolor": "#EBF0F8" + } + }, + "shapedefaults": { + "line": { + "color": "#2a3f5f" + } + }, + "ternary": { + "aaxis": { + "gridcolor": "#DFE8F3", + "linecolor": "#A2B1C6", + "ticks": "" + }, + "baxis": { + "gridcolor": "#DFE8F3", + "linecolor": "#A2B1C6", + "ticks": "" + }, + "bgcolor": "white", + "caxis": { + "gridcolor": "#DFE8F3", + "linecolor": "#A2B1C6", + "ticks": "" + } + }, + "title": { + "x": 0.05 + }, + "xaxis": { + "automargin": true, + "gridcolor": "#EBF0F8", + "linecolor": "#EBF0F8", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "#EBF0F8", + "zerolinewidth": 2 + }, + "yaxis": { + "automargin": true, + "gridcolor": "#EBF0F8", + "linecolor": "#EBF0F8", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "#EBF0F8", + "zerolinewidth": 2 + } + } + }, + "title": { + "text": "Median earnings of adults in parliamentary constituencies" + }, + "width": 800, + "xaxis": { + "anchor": "y", + "domain": [ + 0, + 1 + ], + "gridcolor": "lightgray", + "range": [ + 30, + 85 + ], + "tickvals": [], + "title": { + "text": "" + }, + "zerolinecolor": "lightgray" + }, + "yaxis": { + "anchor": "x", + "domain": [ + 0, + 1 + ], + "gridcolor": "lightgray", + "range": [ + -50, + 2 + ], + "tickvals": [], + "title": { + "text": "" + }, + "zerolinecolor": "lightgray" + } + } + } + }, + "metadata": {}, + "output_type": "display_data" } ], "source": [ - "# from policyengine.utils.charts import *\n", - "# from policyengine import Simulation\n", - "\n", - "\n", - "# sim = Simulation(\n", - "# country=\"uk\",\n", - "# scope=\"macro\",\n", - "# time_period=\"2025\",\n", - "# options={\n", - "# \"include_constituencies\": True,\n", - "# }\n", - "# )\n", - "\n", - "# add_fonts()\n", - "\n", - "# def adult_earnings_median(sim):\n", - "# adult = sim.calculate(\"age\").between(18, 65)\n", - "# earnings = sim.calculate(\"employment_income\")\n", - "# return earnings[earnings > 0][adult].quantile(0.5)\n", - "\n", - "# sim.calculate(\n", - "# \"macro/gov/local_areas/parliamentary_constituencies\",\n", - "# metric=adult_earnings_median,\n", - "# chart=True\n", - "# ).update_layout(\n", - "# title=\"Median earnings of adults in parliamentary constituencies\",\n", - "# ).write_image(\"pictures/parliamentary_earnings.png\", scale=6)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "![](pictures/parliamentary_earnings.png)" + "from policyengine.utils.charts import *\n", + "from policyengine import Simulation\n", + "\n", + "\n", + "sim = Simulation(\n", + " country=\"uk\",\n", + " scope=\"macro\",\n", + " time_period=\"2025\",\n", + " options={\n", + " \"include_constituencies\": True,\n", + " }\n", + ")\n", + "\n", + "add_fonts()\n", + "\n", + "def adult_earnings_median(sim):\n", + " adult = sim.calculate(\"age\").between(18, 65)\n", + " earnings = sim.calculate(\"employment_income\")\n", + " return earnings[earnings > 0][adult].quantile(0.5)\n", + "\n", + "sim.calculate(\n", + " \"macro/gov/local_areas/parliamentary_constituencies\",\n", + " metric=adult_earnings_median,\n", + " chart=True\n", + ").update_layout(\n", + " title=\"Median earnings of adults in parliamentary constituencies\",\n", + ")" ] }, {