Jump to content
We've recently updated our Privacy Statement, available here. ×

Box Plot Q3 Calculation


Go to solution Solved by Andrew Berridge,

Recommended Posts

When working with a box plot or violin chart. The Q3 result is different to what I get in excel and chat gpt.
Using simple values as an example. 3 , 4 , 5 , 5 , 7, 8 , 9 , 10 , 11 , 11, 12.
Q3 in excel = 11 
Spotfire = 10.5 

from chat gpt
 

  1. Median (Q2):

    • The dataset has an odd number of values, so the median is the middle value.
    • Median (Q2) = 8 (the 6th value in the sorted dataset)
  2. First Quartile (Q1):

    • Counting from the start, Q1 is the median of the first half of the dataset.
    • Q1 = median of (3, 4, 5, 5, 7) = 5 (the 3rd value in the sorted dataset)
  3. Third Quartile (Q3):

    • Counting from the end, Q3 is the median of the second half of the dataset.
    • Q3 = median of (9, 10, 11, 11, 12) = 11 (the 4th value in the sorted dataset)

So, for the given dataset, the median (Q2) is 8, the first quartile (Q1) is 5, and the third quartile (Q3) is 11.

image.thumb.png.f99b47ef6f441a4c4d70ec3710ba5c24.png

 

Link to comment
Share on other sites

  • Solution

Hi Brian,

Great question!

As it happens, there are many different methods to calculate the quartiles.

Take a look at this Wikipedia page. There are at least 4 standard methods for calculating them:

https://en.wikipedia.org/wiki/Quartile

R can use one of 9 different methods...

Spotfire, and the Violin Mod use the type 7 method here:

https://www.rdocumentation.org/packages/stats/versions/3.6.2/topics/quantile

This is the default for R, and if it's good enough for R, I would say it's good enough for Spotfire.

However, if you absolutely NEED it to match Excel, then I could consider implementing the Excel-type calculations for the Violin Mod, as an option.

Let me know in a reply!

Thanks,

Andrew (Violin Mod author, Spotfire Field Tech Team)

 

 

Link to comment
Share on other sites

Hello Andrew 

Thank you for the reply and for the link to the explanation. 

Thanks for the offer to alter the mod to match excel, however now that I have an understanding of how it is calculated it is all good as I will be able to explain it in the visualization.

Cheers 
Brian

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...