3 Replies Latest reply on Dec 8, 2018 1:16 PM by Yuri Fal

    Box Plot Custom Whisker Value

    Jennifer VonHagel

      Hello community,


      I have very specific requirements for a box plot chart.  I will have multiple box plots shown by dimension, and each set of marks and corresponding box plot need to be assigned specific colors.  The formatting and end result prettiness of this chart is really important.  There will always be multiple dimension values shown in the same view - probably at least 15.


      Using the principles of Yuri Fal's response in this thread Educational Brain Teaser: Coloring the Boxes on Box and Whisker Plots , I've gotten to a place of being able to assign colors to each dimension in the sample dataset attached.


      However, I need the whiskers of the box plot to be within 0.5 of the IQR, not within 1.5 of the IQR (see screenshot box plot options below).


      I can easily calculate all the various components of the box plot, including my custom whisker values...

      Median: percentile(value_at_some_fixed_level,.5)

      1st Quartile (start of box): percentile(value_at_some_fixed_level,.25)

      3rd quartile (end of box): percentile(value_at_some_fixed_level,.75)

      IQR (interquartile range: 3rd quartile - 1st quartile)

      Lower Whisker (1st Quartile  -  0.5*IQR)

      Upper Whisker (3rd Quartile  +  0.5*IQR)


      ...and then add reference lines and distribution bands to simulate whiskers and the box, but the formatting looks terrible. The reference lines and bands necessarily span the entire height of each subcategory's row, and there is no good way to get the difference colors per subcategory.  The whisker height in the scenario would also be the entire height of each row, which again just doesn't look nice. With this option there isn't a really good way to get the black lines that extend from the box to the whiskers (I could maybe do a gantt style chart on a dual axis, but then I have no chance at all to create the different box colors based on a gantt dual axis).


      I've looked at Tableau extensions to see if there were any further box plot options, and didn't find anything.


      I've heard Tableau is essentially an XML file. Is there any way for me to hack into the backend and just change the 1.5 of IQR to 0.5?  Or any other ideas?




        • 1. Re: Box Plot Custom Whisker Value
          Yuri Fal

          Hi Jennifer,


          Thank you for posting a challenging question.


          First, for Box Plot ref line one couldn't choose any option

          other than 'standard' (which is 1.5 IQR) or 'minmax' --

          there are the two only possibilities encoded in the XML.


          Though we can't tell Tableau to draw whiskers at 0.5 IQR

          (or any arbitrary number), we could modify the distribution

          (of the Marks on a view) so that the 'minmax' Box Plot

          (for this particular distribution) would be the same (drawn)

          as the 'target' one we could have for the original distribution.


          How this 'modification' of the original distribution would look like?

          Imagine 'snapping' all the 'outlier' Marks -- those at +0.5 IQR (and more)

          from the Upper Hinge and -0.5 IRQ (and less) from the Lower Hinge --

          to the Top / Bottom of the respective Whisker (exactly at 0.5 IQR).

          For such a distribution the Hinges don't change, and the 'minmax'

          Whiskers to be at 0.5 IQR (or at the original Min / Max if in).


          With this 'modified distribution' in mind the problem still remains

          how to overlay the 'modified' Box Plot on the original Marks.


          Pages to the rescue :-)


          The observation that Tableau is drawing a distinct set of Ref Lines

          for each Page would lead to using two sets of Marks -- the original

          and the 'modified' (i've used a Union and a [Table Name] for that) --

          then set the Page control to show the last page (with the 'modified') --

          using Page History option to draw the original Marks, too --then hiding

          the 'modified' Marks somehow -- using Shape and Size here -- to get something like this:

          Screenshot 2018-12-08 at 19.12.58.png


          The final view is not 'perfect' for a someone 'purist' --

          as it contains the 'modified' Marks (albeit small hence 'hidden').

          But i couldn't find a way to make it 'simple and clean'.


          Please find the attached.




          1 of 1 people found this helpful
          • 2. Re: Box Plot Custom Whisker Value
            Jennifer VonHagel

            Wow, this is amazing.  In all my years of Tableau I haven't given pages much thought, this is really creative.


            I opened a ticket with Tableau on this issue. They didn't find a solution but did offer to add an enhancement request to allow custom calculations for whiskers on the box plot chart type.  I was going to close this question but decided to leave it open just in case someone had some lightning bolt idea.  Glad I did!




            • 3. Re: Box Plot Custom Whisker Value
              Yuri Fal

              I would be glad to see this 

              to be available out-of-the-box.