Announcement

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

  • overlapping graph lines are obscured

    Hi there

    I would like to plot multiple lines on a graph, but often these lines overlap, in which case Stata (quite understandably) obscures one line with another.
    Can anyone suggest some good techniques for slightly displacing the overlapping lines so that they are all visible? I recognise that any displacement would make it look as though one rate is higher/lower than another (when they are, in fact, the same), but I'm fine with that.

    Below is an example.

    With thanks

    Code:
    clear
    input int year float(rate1 rate2 rate3 rate4)
    1999 2 2 12 12
    2000 3 3 13 13
    2001 4 4 14 14
    2002 5 5 15 15
    2003 6 6 16 16
    2004 7 7 17 17
    2005 8 8 18 18
    end
    line rate1 rate2 rate3 rate4 year, yscale(range(0, .1 )) ylabel(#5)

  • #2
    You could reshape long and then call up fabplot (SSC). See https://www.statalist.org/forums/for...e-on-ssc/page2 and so on.

    Code:
    clear
    input int year float(rate1 rate2 rate3 rate4)
    1999 2 2 12 12
    2000 3 3 13 13
    2001 4 4 14 14
    2002 5 5 15 15
    2003 6 6 16 16
    2004 7 7 17 17
    2005 8 8 18 18
    end
    
    reshape long rate, i(year) j(which)
    
    fabplot line rate year, by(which) xtitle("") frontopts(lw(medthick))

    Comment


    • #3
      Can anyone suggest some good techniques for slightly displacing the overlapping lines so that they are all visible? I recognise that any displacement would make it look as though one rate is higher/lower than another (when they are, in fact, the same), but I'm fine with that.
      There is no magic to offsetting beyond adding a constant value to each observation.

      Code:
      gen rate11= rate1+0.25
      gen rate31= rate3+0.25
      line rate11 rate2 rate31 rate4 year, yscale(range(0, .1 )) ylabel(#5)

      Comment


      • #4
        Thanks very much for these replies. I think adding a constant value to each observation will have to do for me.
        Thanks again.

        Comment


        • #5
          See also https://www.statalist.org/forums/for...ailable-on-ssc

          Comment

          Working...
          X