Image copyright PA

Scotland's population continued to increase last year, rising to a record 5,404,700.

The National Records of Scotland (NRS) figures showed an increase of 31,700 (0.6%) people over the year to the end of June 2016.

It said the increase was due to migration, with 31,700 more people moving to Scotland than leaving.

The number of deaths exceeded births by 800, while other changes resulted in an increase of 800 people.

These other changes included variations in the prison population and in the number of armed forces personnel stationed in Scotland.

The mid-year population estimate figures for 2016 show:

Scotland's population has increased by 6% since 1996 (when it was 5,092,190)

Migration

Image copyright Thinkstock

Migration from the rest of the UK was higher than from overseas (46,300 against 40,400)

But more people left to live in the rest of the UK than went overseas (37,500 against 17,500)

There was a net gain of 22,900 from overseas and 8,800 from the rest of the UK

Migration to Scotland from the rest of the UK has been higher than from overseas in every year since 2000 except for 2010 and 2011

The peak for in-migrants from overseas was 47,400 in the year to mid-2010.

The peak for in-migrants to Scotland from the rest of the UK was 61,900 in 2003-2004

The past year saw a 5% drop in out-migration to overseas

The peak age for migration into Scotland from overseas is 23

The peak ages for migration out of Scotland to overseas are between 23 and 26

Ageing population

Image copyright Thinkstock

The increase in the population of older age groups has been much higher than younger age groups over the past 20 years

The largest rise has been in the 75 and overs (+31%)

The 0 to 15 age group has decreased most (-10%) over 20 years

18% of the population are now aged over 65

People under 16 make up 17% of the population

65% of the population are aged 16 to 64

The highest proportion of population aged 16-64 is found in the city council areas of Glasgow, Edinburgh and Aberdeen at 70%

The Western Isles, Argyll and Bute, Dumfries and Galloway, South Ayrshire and Scottish Borders have the lowest proportion of 16-64s and the most 65 and over.

Geographical spread

Image copyright SamRyley

Last year's population increase was 0.59%

Edinburgh had the largest increase with 1.68%

The Western Isles saw the biggest decrease in population in percentage terms (-0.63%)

Glasgow (+1.44%), Midlothian (+1.40%), East Lothian (+1.01%), Stirling (+0.99%) and East Renfrewshire (+0.94%) also saw substantial population rises

Population decreases affected Inverclyde (-0.43%), Angus (-0.33%), Aberdeen City (-0.22%), North Ayrshire (-0.18), Dumfries and Galloway (-0.10%) and Clackmannanshire (-0.02%)

East Renfrewshire, East Dunbartonshire and Midlothian had the highest percentage of people moving to the area from within Scotland

More women than men

Image copyright Thinkstock

There are more females than males, especially among people over 75

The average for Scotland is 95 men for every 100 women

Shetland is the only council area with more men than women (103 to every 100)

East Renfrewshire, West Dunbartonshire, North Ayrshire and South Ayrshire had the fewest men (91) per 100 females

Population density

Image copyright Thinkstock