ArcGIS Blog

Arcade

ArcGIS Online

Make Population Pyramids in Your Pop-ups with Arcade

By Diana Lavery and Laura Phoebus

Population pyramids are a type of chart that is great for visualizing the age structure and sex ratio of a given population. They are typically shown as two back-to-back bar charts, with the left side representing males and the right side representing females, with age groups increasing on the vertical axis. Population pyramids are used by urban planners, healthcare policy makers, economic analysts, and many more.

How We Did It

ArcGIS Online offers multiple styles of built-in chart elements for pop-ups, but to create the population pyramid chart we needed a more custom approach. These examples below show how you can use HTML + Arcade to build a custom chart.

Data Structure is Important

A major element of the population pyramid is data that divides age and sex into separate fields. The USA 2020 Census Population Characteristics dataset in the Living Atlas provides that structure. This layer is symbolized such that dark green counties are predominantly urban, and dark yellow counties are predominantly rural.

Screenshot of card for USA 2020 Census Population Characteristics layer. Feature service by esri_demographics.
A glimpse of the fields in this layer: Females age 0-4 years, Females age 5-9 years, Females age 10-14 years, Females age 15-17 years, Females age 18-19 years. These fields repeat for Males.

With all the data in separate fields we can start to construct the Arcade expression. Population pyramids group by age, so the first step is to create an array that specifies those groupings. Then we need to set up two more arrays that will hold the fields for the two sides of the pyramid (male and female).

Snippet of the Arcade code showing an array being defined called ageGroups = ['85+','80-84','75-79','70-74','65-69', ... ] Then two more arrays called maleFields and femaleFields contain the specific fields in the layer.

To build the HTML chart, we need to essentially create a table where each row shows one of those age groups. Then inside each row, add a bar for male and female populations. Explore the full Arcade expression in this map’s pop-up configurations to see how the chart dynamically scales based on the data.

Snippet of the Arcade code showing the HTML chart getting built. It uses a counter to loop through each element in the ageGroups array to create a new row in the pyramid.

What Population Pyramids Reveal

While some population pyramids are truly pyramid-shaped, the phrase “population pyramids” means these types of charts, regardless of the shape. In fact, different shapes can reveal different types of communities. Here are some examples.

Youthful Populations

Youthful populations are depicted in population pyramids that are bottom-heavy, with lots of population in the childhood years. For example, the population pyramid for Bonneville County, ID shows a roughly triangular shape.

Bonneville County, ID is green on the map, depicting a predominantly urban setting. In the pop-up, the population pyramid has a triangular shape such that the bars on the bottom (younger ages) are largest, and they generally get progressively smaller and smaller towards the top as the age groups increase.

Stable Populations

Beehive-shaped pyramids reflect steady growth. Often the female side is larger than the male side starting at around the 75+ age groups, reflecting the fact that women’s life expectancy is slightly higher than men’s. This is true in Shelby County, TN, as well as in many other counties.

Shelby County, TN is also green in the map, depicting an urban setting. The population pyramid has relatively similar bars for all age groups except at the very oldest groups, starting around age 70 (very top groups in the chart). The bar for age 85+ for females is about double the size of the 85+ bar for males.

Aging Populations

The inverted triangle shape, especially in the youngest age groups, shows an aging population. For example, in Cumberland County, ME, there are fewer 0-4 year-olds than 5-9 year-olds, and fewer 5-9 year-olds than 10-14 year-olds, and so on. This continues up until ages 30-34, suggesting a shrinking population. Manatí Municipio, PR is experiencing a similar situation.

Cumberland County, ME is very light green in the map, depicting slightly more urban than rural population. The population pyramid toward the younger ages at the bottom has an inverted triangle shape.
Manati Municipio, PR is dark green in the map, depicting an urban population. The population pyramid toward the younger ages at the bottom has an inverted triangle shape.

Male-Skewed Populations

When the left side is noticeably bigger than the right side of the pyramid, particularly among the adult populations, this can signal the presence of a military facility (such as in Onslow County, NC, home to Camp Lejeune) or a correctional facility (such as in Lassen County, CA, home to a state prison).

Onslow County, NC is light green in the map, depicting slightly more urban than rural population. The population pyramid has very large bars for male ages 15-19 and 20-24.
Lassen County, CA is yellow due to its rural population. The population pyramid has much larger bars for males than for females starting at the 15-19 age group, and continues this way until the very top age groups.

College Towns

Populations with a visible bump in the 18-24 age groups are most often college towns in small counties. In small counties, the university can make a large difference in the overall population. For example, Montgomery County, VA is home to Virginia Tech.

Montgomery County, VA is light green in the map, denoting a slightly more urban than rural population. The population pyramid has very large bars for both sex groups in ages 15-19 and 20-24.

Early-Career Urban Centers

Major cities have long been destinations for young adults starting out their careers. These dark green counties in the map are predominantly urban, such as New York County, NY and San Francisco County, CA have a bulge in the 20 – 34 age groups.

New York County, NY is deep green in the map due to its urban population. The population pyramid has very large bars starting in age groups 20-24 through 35-40.
San Francisco County, CA is deep green in the map due to its urban population. The population pyramid has very large bars starting in age groups 20-24 through 35-40.

Recreation and Retirement Communities

Much like college towns and urban centers, recreation and retirement communities attract people in a specific stage of life. In-migration in older ages can be seen in the large bars for 55-74 age groups. Two examples of this are Horry County, SC, and Charlotte County, FL.

Horry County, SC is green in the map, meaning it has an urban population. The population pyramid has very large bars starting in the 55-59 age group.
Charlotte County, FL is green in the map, meaning it has an urban population. The population pyramid has very large bars starting in the 60-64 age group, and very small bars for the younger age groups.

Missing-Workforce Populations

An hourglass shape reveals lots of children and lots of older adults relative to working-age adults. This can be seen in both Hickman County, KY and Butte County, SD. In places such as these, children in the care of grandparents may be common.

Hickman County, KY is yellow in the map, meaning it has a rural population. The population pyramid is roughly hourglass-shaped, meaning it has large bars in the children and teens age groups, and large bars in the 60+ age groups, but small bars in the 20-59 age groups.
Butte County, SD is faintly yellow in the map, meaning it has slightly more rural population than urban. The population pyramid is roughly hourglass-shaped, meaning it has large bars in the children and teens age groups, and large bars in the 60+ age groups, and smaller bars in the 20-59 age groups.

Population Pyramids Are Not Just for Population

Population pyramids can be used to visualize any continuous measure (in this case, age) with two binary groups (in this case, sex). For example, we created a pop-up for this map that shows housing cost burden by owner/renter status.

Percent of income spent on housing is the continuous variable on the y-axis.

For best results, make sure the bins along the y-axis are as close to “equal-interval” as you can get. For age groups, all were 5-year intervals, with the exception of the top-coded 85+ group. For the housing cost burden, they were all 10% intervals, with the exception of the top group.

Try experimenting with other types of charts too! Below are examples of a stacked bar chart and a grouped bar chart that display the same owner/renter data.

Alternative ways of stacking the charts. Rather than stack the bars back-to-back such as in the pyramids, this shows two other possibilities: stacking to emphasize overall magnitude of the groups up the y-axis, or left-justifying both charts to emphasize the relative size of each of the two binary groups on the x-axis (owners and renters).

Check out the full Arcade expression and experiment with your own data using the template expressions in this Population Pyramids with Arcade map. The Arcade expressions are stored within the pop-up configurations.

Have you made population pyramids in your work? Share it in Esri Community.

Share this article

Leave a Reply