Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Secondary Axis in Box Plot

    Hello all.

    I was trying to create a box plot with a secondary axis on it. I have looked at Statalist on previous posts about this and came across a thread from 2009 which says it is not compatible. Is this still the case or is there any way around?

    Thank you,

  • #2
    What does that mean precisely? I think you need to explain that in some other way.

    Why not give the precise URL of the "thread from 2009"?
    Last edited by Nick Cox; 02 Oct 2014, 07:20.

    Comment


    • #3
      Dear Nick,

      Thank you for your quick reply. There was a problem with the site when I wanted to post the first time that is why it is duplicated. Sorry about that.

      I want to add a secondary axis to a box plot including in the left axis a variable measured in percentage terms (tax due as a proportion of theoretical tax liability) and in the right axis the same variable measured in pounds. In the x axis I have income.

      graph box percgap gap, over(tincq)

      This is the thread I was looking at: http://www.stata.com/statalist/archi.../msg00509.html

      Comment


      • #4
        http://www.ats.ucla.edu/stat/stata/code/twboxplot.htm describes how to make boxplots within graph twoway. It may meet your needs.

        Comment


        • #5
          The same thread mentions that stripplot (SSC) supports secondary axes by virtue of being a wrapper for twoway. I've not tried that as far as I can recall.

          EDIT. But why not?

          Code:
          sysuse auto, clear
          
          set scheme s1color
          
          stripplot mpg, over(rep78) box pctile(10) outside ms(none) vertical ///
          yaxis(1 2) ytitle("Gallons per 100 miles", axis(1)) ///
          yla(10 12.5 "8" `=100/7' "7" `=100/6' "6" 20 "5" 25 "4" `=100/3' "3" 40 "2.5", axis(1) ang(h)) ///
          ytitle("Miles per gallon", axis(2)) yla(, ang(h) axis(1))
          This is code for box plots with whiskers to 10 and 90 percentiles, with points outside shown individually and separate scales for units and 100 times their reciprocals.

          Click image for larger version

Name:	stripplot_box_oct2.png
Views:	4
Size:	27.6 KB
ID:	281085
          Attached Files
          Last edited by Nick Cox; 02 Oct 2014, 08:04.

          Comment


          • #6
            These are the two graphs I wanted to put together. So for each category in the x axis I want both boxes (from the different graphs) to appear one by each other and have on the left axis the % and on the right axis the pounds.

            I generated them as this:

            graph box gap if A==1, over(inc)
            graph box percgap if A==1, over(inc)

            I can however do this;

            graph box gap percgap if A==1, over(inc) but they are completely different scales and therefore I need a second axis.

            Using stripplot I get I cannot use the over command when I introduce two variables to plot.

            stripplot pgaphhld taxgap if SE==1, box yaxis(2) over(incq)
            over() may not be combined with more than one variable

            Thank you both.

            Last edited by Ana Gonzalez; 02 Oct 2014, 08:05.

            Comment


            • #7
              Unless you can specify a one-to-one closed-form relationship between your percent variable and your pound variable. I can't understand your problem as that of wanting a secondary axis. If you just have two related variables, then you have already solved your problem.

              Comment

              Working...
              X