Data Visualization – Ready reference – Do the math

Stas Udotov
Chief Design Officer

Most of the math we use in charting is fundamental algebra and statistics. Yet most of us continue to make simple mistakes. Should we ever take an average of two percentages? How do we calculate percentage change: the new number minus the old number divided by the new number? Or divided by the old number? What is a log scale?

In addition to basic math skills, we also need knowledge of the market — the more, the better. What are the major stock indexes? How do we chart currency fluctuations that affect our global business?

These are all formulas and facts that save you time when you need to deliver quality work on a tight deadline. You will find them all here at your fingertips in this chapter.

Mean, median, and mode

Which should you use?

The mean, or average, uses every value in a data set. It works well when each observation should count the same. But very high or low values can pull it away from what is typical.

The median shows the middle of an ordered data set. Because extreme values have less effect on it, it is useful for uneven data, such as home prices or household incomes.

The mode shows the most common value or category. Use it when you want to show which result appears most often.

Definitions

The mean is found by adding all values and dividing by the number of data points.

The median is the middle value when the data is in numerical order. If the data set has an even number of observations, find the median by averaging the two middle values.

The mode is the value that appears most often. A data set can have more than one mode if several values share the top count.

Example: The following data set shows the number of cars sold in a day by each of nine divisions.

Dot chart showing values of 1, 2, 3, 3, 4, 7, 7, 7 and 11 across nine divisions, illustrating a mean of 5, median of 4 and mode of 7.

Standard deviation

Standard deviation shows how widely values are spread around the mean. For stock returns, a higher standard deviation means greater swings.

Low standard deviation shown as a narrow curve around the mean, compared with a wider curve for high standard deviation, with the population standard deviation formula below.

Example: In business, standard deviation is often used to measure price swings by looking at how much percent changes in prices vary over time.

Standard deviation calculation for price changes of 3%, 1%, 9% and 19%, with a mean of 8% and squared deviations totaling 196, yielding 7% volatility.

For the quants:

Volatility is usually shown on an annual basis.

To calculate annualized volatility, follow these steps:

  1. Find the standard deviation of daily returns.

  2. Multiply this standard deviation by the square root of the number of trading days in a year.

Annualized volatility equals daily standard deviation multiplied by the square root of the number of trading days in a year.

Probability

Probability shows how likely an event is to occur. Although the result of one trial may be uncertain, patterns often appear when the same experiment is repeated many times. Probability theory helps measure uncertainty in many fields, from insurance risk to new drug tests in clinical trials.

Symmetric probability distributions

A symmetric distribution has the same shape on both sides of its center. Some symmetric distributions follow a bell shape, as test scores sometimes do.

Example: Roll two fair, six-sided dice many times and plot the sum of each roll. Over many trials, the results move toward a symmetric, triangular distribution centered on 7. Sums near the center occur more often than those at either end.

Chart of sums from rolling two six-sided dice, listing 36 possible combinations. Seven is the most likely sum; two and twelve are the least likely.

Fat tails, often tied to high kurtosis, mean that extreme gains or losses happen more often than a normal bell curve would suggest. Although it is widely used, the normal distribution can downplay the chance of extreme events, such as the 1987 stock market crash.

Comparison of a normal distribution and a fat-tailed distribution, showing that extreme gains and losses are more likely with fat tails.

Skewed probability distributions

Skewed distributions show data that is spread unevenly, with a longer tail on one side. Common examples include personal income and losses from credit defaults.

Uneven distribution of income

Personal income is a well-studied example of a skewed distribution: most people earn in the lower or middle range, while a smaller group earns much more. Researchers study this pattern to understand the income gap, poverty, and economic growth.

Right-skewed household income distribution, with most households concentrated at lower incomes and a long tail extending toward higher incomes.

A small risk of a substantial loss

Even bonds with a low chance of default carry some risk of losing part or all of the invested principal during the holding period.

Probability distribution of a bond’s market value, concentrated near the original investment with limited gains and a long left tail showing a small chance of substantial losses from default.

The psychology of risk

A risk-taker focuses on the remote chance of winning the lottery. A risk-averse person worries about an equally unlikely danger, like someone striking them with lightning.

Both give weight to rare, extreme outcomes—the events found in the tails of a probability distribution.

Average vs. weighted average

The Dow Jones Industrial Average is a price-weighted index, meaning stocks with higher share prices have a greater effect on its value.

A simple average gives every observation the same weight. A weighted average gives some observations more weight, based on things such as duration, volume, or money value. Choose weights that fit the goal of the analysis; they do not have to follow a straight line.

Example: A simple average of stock prices gives equal importance to prices recorded during quiet and busy trading periods. Weighting prices by trading volume gives more weight to the prices at which more shares changed hands.

Table comparing a simple average share price of $18 with a volume-weighted average of $19, calculated by dividing $49,400 in traded value by 2,600 shares.

Volume-weighted average price

Buyers and sellers sometimes agree to trade at the average price weighted by trading volume over a set period. This is called a VWAP trade.

Moving average

A moving average smooths short-term swings in a data series, making the trend easier to see.

Example: A four-day moving average applied to a data series with many swings.

Table and line chart showing how a four-period moving average smooths a fluctuating data series, revealing an upward trend from 3.75 to 11.50.

You can plot a moving average at the center or the end of the period used to calculate it.

Logarithmic scale

We do not always feel equal time gaps in the same way. The gap between one and two years from now may feel larger than the gap between 10 and 11 years. A logarithmic time axis can match this view by giving more space to shorter time spans and less to longer ones.

X-axis log scale

A logarithmic scale works across a wide range of values. Equal spacing shows equal ratios, not equal gaps.

When the focus is on the near term, a log scale on the time axis makes shorter spans easier to tell apart while keeping more distant periods visible.

Example: A yield curve showing Treasury bills, notes, and bonds across different maturities.

Treasury yield curves for today and one year ago, with maturities from one month to 30 years on a logarithmic axis. Today’s yields are lower, especially at shorter maturities.

Y-axis log scale

A logarithmic y-axis shows proportional changes instead of absolute differences. Equal percent increases take up the same vertical space, no matter the starting value.

Example: A 10-point rise from 10 to 20 is a 100% gain, while a rise from 100 to 110 is 10%. From 1,000 to 1,010, the gain is just 1%. A logarithmic scale shows these differences with smaller and smaller vertical moves.

Logarithmic y-axis showing progressively smaller vertical changes for 10-point increases from 10 to 20, 100 to 110 and 1,000 to 1,010, representing gains of 100%, 10% and 1%.

A logarithmic y-axis is especially useful for showing stock prices or market indexes over long periods.

Logarithmic scales can use different bases, but base 10 is a practical and easy-to-read choice for most charts.

log_{10}10 = 1 log_{10}50 = 1.7 log_{10}100 = 2 log_{10}500 = 2.7 log_{10}1000 = 3 log_{10}5000 = 3.7 log_{10}10000 = 4

Comparable scales

When you compare two or more data series, use scales that make the comparison clear. Readers see gentle slopes as smaller increases and steeper slopes as larger increases. The example below shows how matching the y-axis scales to equal percent changes makes the relative performance of two stocks easier to judge.

Example

Two stock charts with identical slopes: Stock A rises from $20 to $25, a 25% gain, while Stock B rises from $100 to $105, a 5% gain, obscuring their different percentage returns.
Noncomparable scales Both stocks rise by $5, but their percentage gains differ. Showing a 25% gain and a 5% gain as identical movements obscures the difference in their relative performance.
Table and chart comparing one-year gains: Stock A rises from $20 to $25, or 25%, while Stock B rises from $100 to $105, or 5%, shown on a shared percentage scale.
Percentage changes On the same percentage scale, Stock A’s 25% gain produces a steep upward line, while Stock B’s 5% gain creates a gentler slope.
Stock charts with proportional y-axis scales showing Stock A rising from $20 to $25, a 25% gain, and Stock B rising from $100 to $105, a 5% gain.
Comparable scales Set the y-axis scales so that equal percentage changes cover the same vertical distance. This makes it clear that Stock A outperformed Stock B.

Creating comparable scales step by step

Stock P trades between $21 and $24, while Stock Q trades between $105 and $110.

Stock P fluctuates between $21 and $24. Its trading range is calculated as (24 − 21) ÷ 21 × 100%, or approximately 14.3%.
1. Compare the trading ranges as percentages and set the scale for the stock with the larger range first. Stock P spans approximately 14%, while Stock Q spans less than 5%.
Stock Q’s vertical scale with a lower bound of 100 and an upper bound not yet specified.
2. Choose a convenient, rounded value for the lower limit of the other chart’s scale, such as 1, 2, 5, 10, 50, or 100.
Stock P’s scale starts at 20 and Stock Q’s at 100, establishing a scale ratio of 5: 20 × 5 = 100.
3. Divide the lower limit of the second scale by the lower limit of the first to find their ratio.
Multiply Stock P’s upper scale value of 25 by 5 to obtain Stock Q’s upper value of 125, creating proportional scales of 20–25 and 100–125.
4. Multiply the upper limit of the first scale by this ratio to determine the upper limit of the second.
Stock P and Stock Q on comparable y-axis scales, each spanning 25%: $20–$25 and $100–$125. Stock P fluctuates more in percentage terms, ranging from $21 to $24 versus Stock Q’s $105 to $110.
5. Confirm that both scales span the same percentage increase from their lower to upper limits.

Both graphs now use comparable scales, making the two stocks’ relative performance easy to compare.

Percentage change

When a value falls below its original level, the change is shown as a percentage decrease.

Example: If a value drops from 100 to 90, that is a 10% decrease.

Percentage change from 100 to 90: (90 − 100) ÷ 100 × 100% = −10%, a 10% decrease.

A change in value can be shown as a percentage of the original amount.

Percentage change equals (new value − old value) ÷ old value × 100%. Examples show an increase from 2 to 3 is 50%, and from 2 to 5 is 150%.

Changing the starting point of a data series changes the baseline used to calculate percent changes, which can produce different results.

Table and line charts showing how the baseline affects percentage change. January–May values are 10, 15, 12, 6, and 9. Changes from January are 0%, +50%, +20%, −40%, and −10%; changes from February are 0%, −20%, −60%, and −40%.

Re-indexing to 100 or 0

Starting from a baseline of 0 or 100 makes changes easier to read. A rise from 100 to 113 clearly shows a 13% gain, while a rise from 123 to 139 takes more work to see as a similar increase.

Data table and line chart showing values of 4, 6, 5, 5, and 7: rising, declining, remaining steady, then rising to the highest value.

Re-indexing to 100 rescales a data series so its first value equals 100.

Table and line chart showing data rebased to 100 using (current value ÷ initial value) × 100. Values 4, 6, 5, 5, and 7 become 100, 150, 125, 125, and 175.

Rebasing to 0 shows each value as a percentage change from the first data point. The following formula gives another way to calculate it.

Table and line chart showing data rebased to 0 using [(current value ÷ initial value) × 100] − 100. Values 4, 6, 5, 5, and 7 become percentage changes of 0%, 50%, 25%, 25%, and 75%.

Familiar round numbers, such as 1,000 or 10,000, can also work as useful baselines, depending on the context. For example, you can show a stock's performance as the changing value of an initial $10,000 investment.

Summary

Data visualization turns raw data into useful insight. By showing patterns in sales, market segments, and customer behavior, it helps teams refine forecasts, understand their audiences, and improve their plans.

Across finance, medical research, and business operations, clear visuals make complex information easier to read and share. Advances in artificial intelligence, virtual reality, and real-time dashboards are expanding how people explore data and use it to make smart choices.

The next article in the Data Visualization series covers percentages. Stay tuned, and subscribe to our mailing list to get the next article on data visualization.

If you missed the previous seven articles from the series, you can read them here:

Dworkz helps B2B SaaS teams design tables, dashboards, and workflows that make complex information easier to use. Need clearer data experiences in your product? Let’s talk

FAQ

When should I use the mean instead of the median?

Use the mean when every value in the data set should count equally and the data is not heavily skewed by very high or low values. Use the median when the data is unevenly spread or has outliers, such as household incomes or home prices, because the median is less affected by extreme values.

Why does standard deviation matter in finance?

Standard deviation helps show how much returns vary around their average. In finance, that spread is often read as volatility: a higher standard deviation means returns are more spread out, and the asset's price may be less predictable. For daily returns, annualized volatility is often estimated by multiplying the daily standard deviation by the square root of the number of trading days in a year.

What is the difference between a simple average and a weighted average?

A simple average gives every observation the same weight, while a weighted average gives more weight to some observations based on things such as trading volume, duration, or money value. For example, a volume-weighted average price gives more importance to prices at which more shares were traded, making it a better match for actual market activity than a simple average of recorded prices.

Why are logarithmic scales useful in charts?

Logarithmic scales are useful when values span a wide range or when proportional change matters more than absolute change. On a logarithmic y-axis, equal percent increases appear as equal vertical distances, which makes growth rates easier to compare over time. On a logarithmic x-axis, shorter time spans can be shown in more detail while longer spans stay visible.

How does re-indexing a data series to 100 help readers?

Re-indexing sets the first value of a series to 100, which makes later changes easier to read as percentage gains or losses from the starting point. For example, a move from 100 to 113 clearly shows a 13% increase. This is especially useful when you compare series that begin at different absolute values.

Read More