Announcement

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

  • Add vertical line with distplot on same plot

    Dear Statalister,
    Please help me to add a vertical line at value of 10 with the below command on same plot.
    distplot area, over(file_name) scheme(s1color) c(J J) lc(red blue green) xla( 0(10)100, valuelabel) yla(0 "0" 1 "1" 0.2(0.2)0.8, format ("%02.1f") ang(h))

    I tried using this code
    distplot area, over(file_name) addplot yline(10) scheme(s1color) c(J J) lc(red blue green) xla( 0(10)100, valuelabel) yla(0 "0" 1 "1" 0.2(0.2)0.8, format ("%02.1f") ang(h))
    but it is showing error.
    Thanks in advance.

  • #2
    I can't see your data or your graph. I also advise strongly against red and green on the same plot given so-called colour blindness.

    But yline(10) gives you a horizontal line. A vertical line would be given by xline(10).

    distplot is from the Stata Journal.



    Comment


    • #3
      Dear Nick,
      I have attached data and plot.
      Code:
      * Example generated by -dataex-. For more info, type help dataex
      clear
      input str14 file_name float area str16 hh_id
      "sample_plot"     .1 "INKNTHA100030000"
      "census_ownland"  .1 "IKN13D0227"      
      "census_ownland" .12 "IKN13D0226"      
      "sample_plot"    .12 "INKNTHA100044000"
      "sample_plot"    .12 "INKNTHA100050000"
      "census_ownland" .12 "IKN13D0229"      
      "sample_plot"    .12 "INKNTHA100043000"
      "sample_plot"    .12 "INKNTHA100044000"
      "census_ownland" .12 "IKN13D0225"      
      "sample_plot"    .12 "INKNTHA100050000"
      "census_ownland" .12 "IKN13D0215"      
      "census_ownland" .13 "IKN13D0315"      
      "census_ownland" .13 "IKN13D0316"      
      "census_ownland" .15 "IKN13D0223"      
      "sample_plot"    .15 "INKNTHA100030000"
      "census_ownland" .15 "IKN13D0224"      
      "census_ownland" .15 "IKN13D0221"      
      "census_ownland" .15 "IKN13D0222"      
      "census_ownland" .15 "IKN13D0312"      
      "sample_plot"    .18 "INGJCHA100002000"
      "sample_ownland" .18 "INGJCHA100030000"
      "census_ownland" .18 "IGJ13B0002"      
      "sample_ownland" .18 "INGJCHA100002000"
      "census_ownland" .18 "IGJ13B0011"      
      "sample_plot"    .18 "INGJCHA100030000"
      "census_ownland"  .2 "IAP13D0983"      
      "census_ownland"  .2 "IAP13D0551"      
      "census_ownland"  .2 "IKN13D0230"      
      "census_ownland"  .2 "IGJ13A0705"      
      "census_ownland"  .2 "IMH13D0204"      
      "census_ownland"  .2 "IKN13D0113"      
      "census_ownland" .25 "IKN13D0066"      
      "sample_plot"    .25 "INKNTHA100004000"
      "sample_plot"    .25 "INGJBAB100034000"
      "sample_plot"    .25 "INGJBAB100038000"
      "sample_ownland" .25 "INKNTHA100009000"
      "sample_plot"    .25 "INKNTHA100002000"
      "census_ownland" .25 "IAP13A0358"      
      "sample_plot"    .25 "INKNTHA100031000"
      "census_ownland" .25 "IKN13D0391"      
      "sample_plot"    .25 "INKNTHA100044000"
      "sample_plot"    .25 "INAPPAM100057000"
      "census_ownland" .25 "IKN13D0401"      
      "sample_plot"    .25 "INKNTHA100057000"
      "sample_plot"    .25 "INGJBAB100035000"
      "sample_plot"    .25 "INKNBEL100035000"
      "sample_plot"    .25 "INGJBAB100035000"
      "census_ownland" .25 "IKN13D0065"      
      "sample_plot"    .25 "INKNTHA100032000"
      "census_ownland" .25 "IAP13D0806"      
      "census_ownland" .25 "IKN13A0150"      
      "sample_plot"    .25 "INKNTHA100030000"
      "census_ownland" .25 "IKN13D0352"      
      "census_ownland" .25 "IKN13D0296"      
      "sample_plot"    .25 "INKNTHA100038000"
      "sample_plot"    .25 "INGJBAB100035000"
      "census_ownland" .25 "IGJ13A0097"      
      "sample_plot"    .25 "INGJCHA100038000"
      "census_ownland" .25 "IKN13D0075"      
      "sample_ownland" .25 "INKNTHA100008000"
      "census_ownland" .25 "IKN13D0242"      
      "census_ownland" .25 "IKN13D0377"      
      "sample_plot"    .25 "INGJBAB100038000"
      "sample_plot"    .25 "INGJBAB100033000"
      "sample_plot"    .25 "INKNTHA100049000"
      "sample_ownland" .25 "INKNTHA100004000"
      "census_ownland" .25 "IKN13D0369"      
      "sample_plot"    .25 "INGJBAB100045000"
      "sample_plot"    .25 "INMPPAP100043000"
      "census_ownland" .25 "IKN13D0228"      
      "census_ownland" .25 "IKN13D0334"      
      "census_ownland" .25 "IAP13C0025"      
      "census_ownland" .25 "IKN13D0291"      
      "census_ownland" .25 "IKN13D0347"      
      "census_ownland" .25 "IAP13C0176"      
      "census_ownland" .25 "IKN13A0061"      
      "sample_plot"    .25 "INGJBAB100033000"
      "census_ownland" .25 "IKN13D0197"      
      "census_ownland" .25 "IMH13D0312"      
      "sample_plot"    .25 "INGJBAB100047000"
      "sample_ownland" .25 "INKNTHA100007000"
      "census_ownland" .25 "IKN13D0246"      
      "sample_plot"    .25 "INGJBAB100051000"
      "sample_plot"    .25 "INKNTHA100050000"
      "census_ownland" .25 "IKN13D0241"      
      "sample_plot"    .25 "INGJCHA100054000"
      "sample_plot"    .25 "INKNTHA100007000"
      "census_ownland" .25 "IKN13D0314"      
      "sample_plot"    .25 "INKNTHA100049000"
      "sample_plot"    .25 "INKNTHA100041000"
      "census_ownland" .25 "IKN13D0336"      
      "census_ownland" .25 "IKN13D0027"      
      "sample_plot"    .25 "INGJBAB100030000"
      "census_ownland" .25 "IKN13D0261"      
      "sample_plot"    .25 "INGJCHA100033000"
      "sample_plot"    .25 "INKNTHA100037000"
      "census_ownland" .25 "IAP13B0210"      
      "sample_plot"    .25 "INGJBAB100038000"
      "sample_plot"    .25 "INGJBAB100003000"
      "sample_plot"    .25 "INMPRAM100042000"
      end
      Last edited by rahul kumar singh; 29 Nov 2023, 08:46.

      Comment


      • #4
        Thanks, but I have the same advice. Indeed yline(10) makes no sense because the vertical scale necessarily ranges from 0 to 1.

        I have extra advice, which is to draw a quantile plot for log area. Extreme skewness of land area ownership is all too well known, and it is better to use a graph that makes secondary contrasts clearer.

        Comment


        • #5
          Dear Nick, I am replicating a work, in which same plot is drawn so I have the same plot. So can you please help me to modify the above code add a vertical line. or any other plot command that do the same. Thanks

          Comment


          • #6
            Sorry, but I am at a loss to understand how I have not answered your question already: xline(10)

            In any case, why do you need to replicate a poor graph that can be improved? If this is an assignment, that's understood, but beyond the scope of Statalist.

            Comment

            Working...
            X