Incell Dot Plots in Microsoft Excel

Posted on June 10th, 2009 in Charts and Graphs , Learn Excel - 9 comments

Dot plots are a very popular and effective charts. According to dot plots wikipedia article,

Dot plots are one of the simplest plots available, and are suitable for small to moderate sized data sets. They are useful for highlighting clusters and gaps, as well as outliers. Their other advantage is the conservation of numerical information.

Today we will learn about creating in-cell dot plots using excel. We will see how we can create a dot plot using 3 data series of some fictitious data. We will create something like this:
Excel In-cell Dot Plots - Tutorial

Note: If you are new to in-cell charting, I suggest you read the incell bar charts article to understand the concept.

1. Take your data and massage it a bit

Since we are doing an incell variation of dot plot, we need to pre-process the data a little bit. Assuming we have data on revenues of 3 imaginary companies – MegaHard, Grape and Twogle like this:
Dot Plot Data
We need to normalize the data to some meaningful number like 100 (remember, incell graphs print some character for each unit in the data.) so that the in-cell dot plot looks meaningful.

After normalizing the data we will also need to calculate some helper columns so that we can develop the incell dot plot easily. The helper columns (3 of them) will show,

  1. Smallest value in each row – 1
  2. Next smallest value in each row – previous helper column – 2
  3. The largest value in each row – previous two helper columns – 3

Dot Plot Data (Normalized)

Helper columns ?!? why are we doing this?

The helper columns (or intermediate values) are usual practice when we need to pre-process data for dashboards or charts. Once the chart is ready, I usually hide the helper columns as they do not really say anything.

In our case, we are using helper columns since the formulas for plotting the incell dot plot are rather long and we would make then even longer if we don’t use these.

2. Identify Symbols for Each Data Series

This is the simple job. In our case I have shown the symbols we are going to use in the above image. You can find some interesting symbols like triangles, rectangles, circles etc. in a regular font like Arial. Just go to Menu > Insert > Symbol (or Insert > Symbol in Ribbon) to find the symbols you like.

Let us assume the symbols are in the range C5:E5

3. Finally Write the Formulas That Generate the In-cell Dot Plot

Now comes the fun part. We have the normalized data in the range C16:E16, and the helper values  in F16, G16, H16.

For the first row of the dot plot, the formula looks like:
=REPT("-",F16)&INDEX($C$5:$E$5,MATCH(SMALL(C16:E16,1),C16:E16,0))&REPT("-",G16)&INDEX($C$5:$E$5,MATCH(SMALL(C16:E16,2),C16:E16,0))&REPT("-",H16)&INDEX($C$5:$E$5,MATCH(SMALL(C16:E16,3),C16:E16,0))&REPT("-",100-MAX(C16:E16))

huh! it has to be one of the longest formulas I have written in a while.

I thought long and hard about how this formula can be explained and came up with the below illustration.
In-cell Dot Plot - Formula
Once you have the formula for one row, we just need to copy paste it over the entire range to show dot plot for each year of the data. That simple!

Some formula help if you are stuck – REPT() | SMALL() | MATCH() | MAX()

How to Generate 2 Series Dot Plots?

The 2 series dot plots have even simpler formulas. So I am leaving it to your imagination. But when you finish it, the dot plot looks something like this:
2 series dot plot example - microsoft excel

Download the In-cell Dot Plot Template and Make your own Dot plots

The downloadable workbook has examples for 2 series and 3 series in-cell dot plots. Go ahead and play with it.

Further Resources on Dot Plots

Dot plots are not new, there is quite a bit of material and tools available for you to understand and make dot plots. They are proven to be very effective tools for communicating small to medium series of data. I suggest you to read few of these articles to learn more about dot plots.

Naomi’s Article on B-eye Network on Dot Plots

Excel Dot Plots using Bar Charts by Jon Peltier (Also try Excel Dot Plotter Add-in)

Excel User on Dot plots and why they are better

More on In-cell Charts

Incell Bar | Sparklines | Pie charts | Bullet Graphs | w/ Conditional Formatting

| More
Subscribe for PHD Email updates and get a free excel e-book with 95 tips & tricks

Comments
Jon June 11, 2009

seems im having a blonde moment

ive tried following this but couldnt get the standardization to work so used the formula =B3/MAX($B$3:$D$9) * 100

some of the results come out as 11.5 which translates to 12 when removing the decimal places and i noticed that these are highlighted green on the example.
Would it be worth using =INT(B3/MAX($B$3:$D$9) * 100) ?

Cheers

Chandoo June 11, 2009

@Jon.. I have used int just to ensure that we are sending integers to REPT(). But it works with decimal values as well. Excel highlights a cell with green color because it has inconsistent formula wrt. other cells in that region. When you paste the same formula (=B3/MAX($B$3:$D$9) * 100) over the entire region, you wont see the green highlights.

Also, if you know formulas well, you can even turn off this notification to save sometime. Just go to excel options > formula and turn it off.

Gerald Higgins June 11, 2009

This is a neat idea. Strictly speaking, I think we should use characters of equal width.

Chandoo June 11, 2009

@Gerald.. that is a good suggestion…Triangles are good, so are several variations of circles.

Jon June 12, 2009

Ah, thanks, and thanks for the formula tip too.
unfortunately i cant download the examples at work so next time ill wait till i get home and cross check there before posting :)

Martin June 17, 2009

Chandoo, I’ve just landed yesterday in your page, and must say it’s awesome !!

question: I wanna take the incell a step further, and create a UDF called (surprise!!) incell, to which I’ll pass the range of numbers I want to represent.

a first approach is related to the length of the bars, as I’m not sure how to normalize any number as a representation in 10 bars (silly me…).
the second issue might be related to sign. I’d thought on adding spaces prior to positive bars, so when represented they should be “upper”, and the opposite to negatives, so they appear “lower”.

finally, this is what I’ve done so far (not including my previous considerations), starting from your example:
Function incell(rango)
Cadena = “”
For Each m In rango.Count
Cadena = Cadena & (application.WorksheetFunction.Rept(”|”, Round(m.Value / 3, 1))) & Chr(10)
Next m
rango.Select
With selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = True
.Orientation = 90
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With

ActiveCell.Offset(5, 0).Value = Cadena
End Function

Any help will be much appreciated.

Thanks !

Martin June 17, 2009

Here’s an update:

Function incell(rango)
Cadena = “”
Blanco = application.WorksheetFunction.Rept(” “,10)
For Each m In rango.Count
If m.value =>0 then
Cadena = blanco & application.WorksheetFunction.Rept(”|”,Round(INT(ABS(M.VALUE)/MAX(RANGO)*100)))) & Chr(10)
Else
Cadena application.WorksheetFunction.Rept(”|”,Round(INT(ABS(M.VALUE)/MAX(RANGO)*100)))) & Chr(10)
& blanco
Next m

rango.Select
With selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = True
.Orientation = 90
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With

incell = Cadena
End Function

share your wisdom and make it better, please !!

RGds,

Martín.

Martin June 17, 2009

well, that’s quick… this one works fine up to the cell formatting

Function incell(rango)

Cadena = “”
n = rango.Count
For m = 1 To n
repet = Round(Int(Abs(rango(m).Value) / application.WorksheetFunction.Max(rango) * 10))
blanco = application.WorksheetFunction.Rept(” “, 11)
resto = application.WorksheetFunction.Rept(” “, 11 – repet)
If rango(m).Value >= 0 Then
Cadena = Cadena & blanco & application.WorksheetFunction.Rept(”|”, repet) & Chr(10)
Else
Cadena = Cadena & resto & application.WorksheetFunction.Rept(”|”, repet) & Chr(10)
End If

Next m

incell = Cadena
ActiveCell.Select
With selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = True
.Orientation = 90
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
End Function

Now, I can format the incells manually after the formula, but the trick would be to do it when using the formula, if possible… :)

Chandoo June 17, 2009

@Martin: Welcome to PHD and thanks for asking a question. Excel UDFs have a limitation when it comes to cell formatting. You cannot use cell formatting related functionalities from UDFs. However there is a small loophole. You can create shapes using UDFs.

Fabrice, who is a regular at PHD and a wonderful person, has used this little idea to create a really sexy piece of UDF library here: http://sparklines-excel.blogspot.com/ using which you can generate richer and better incell graphs.

If you are planning to write UDFs that can generate incell graphs, you can take a look at his library and get some ideas.

RSS feed for comments on this post. TrackBack URI

Leave a comment

   Name (required)

   E-mail (required, never displayed)

   URL


If you have a question, please ask in the forums

Recommended Excel, Charting, VBA books