Announcement

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

  • Why xlabel failed to work in my graph?

    I want to draw a twoway scatter plot with linear fitted line, the initial graph is like

    Click image for larger version

Name:	QQ截图20160227125059.jpg
Views:	3
Size:	207.3 KB
ID:	1328486


    Notice that the on the x-axis, there is only two labels, represent the minimum and maximum of the variable: floor growth rate. I want to add a more "dense" xlabels using xlabel() option
    HTML Code:
    twoway (scatter share floor_growth if deficit_quart<=1&share>0,mcolor(black) ) ///
           (scatter share floor_growth if deficit_quart>=3&share>0,mcolor(gs10) )  ///
           (lfit share floor_growth if deficit_quart<=3&share>0)  ///
           (lfit share floor_growth if deficit_quart>3&share>0),  ///
           title("LGFV's share") ///
           xtitle("floor growth rate", margin(medsmall))   ///
           ytitle("LGFV purchasing share") ///
           xlabel(-7.5(0.05)1.0, labsize(small))  ///
           legend(order(1 "低债务约束" 2 "高债务约束" ///
           3 "非参拟合(低债务)" 4 "非参拟合(高债务)")) ///
           xlabel(minmax)
    However, the new option makes no change, and even I rewrite the xlabel() option like, the outcome is the same
    HTML Code:
    xlabel(#10,labsize(small))
    I don't know why, maybe I miss something. So please give me some clue, thanks in advance.
    By the way, I use Stata13MP
    Last edited by Zhang_Lu; 26 Feb 2016, 22:04.

  • #2
    You are asking for 171 labels. I guess Stata doesn't believe that you mean what you say. Here is the expansion of your syntax

    Code:
     
    -7.5 -7.45 -7.4 -7.35 -7.3 -7.25 -7.2 -7.15 -7.1 -7.05 -7 -6.95 -6.9 -6.85 -6.8 -6.75 -6.7 -6.65 -6.6 -6.55 -6.5 -6.45 -6.4 -6.35 -6.3 -6.25 -6.2 -6.15 -6.1 -6.05 -6 5.95 -5.9 -5.85 -5.8 -5.75 -5.7 -5.65 -5.6 -5.55 -5.5 -5.45 -5.4 -5.35 -5.3 -5.25 -5.2 -5.15 -5.1 -5.05 -5 -4.95 -4.9 -4.85 -4.8 -4.75 -4.7 -4.65 -4.6 -4.55 -4.5 -4.45 -4.4 -4.35 -4.3 -4.25 -4.2 -4.15 -4.1 -4.05 -4 -3.95 -3.9 -3.85 -3.8 -3.75 -3.7 -3.65 -3.6 -3.55 -3.5 -3.45 -3.4 -3.35 -3.3 -3.25 -3.2 -3.15 -3.1 -3.05 -3 -2.95 -2.9 -2.85 -2.8 -2.75 -2.7 -2.65 -2.6 -2.55 -2.5 -2.45 -2.4 -2.35 -2.3 -2.25 -2.2 -2.15 -2.1 -2.05 -2 -1.95 -1.9 -1.85 -1.8 -1.75 -1.7 -1.65 -1.6 -1.55 -1.5 -1.45 -1.4 -1.35 -1.3 -1.25 -1.2 -1.15 -1.1 -1.05 -1 -.95 -.9 -.85 -.8 -.75 -.7 -.65 -.6 -.55 -.5 -.45 -.4 -.35 -.3 -.25 -.2 -.15 -.1 -.05 0 .05 .1 .15 .2 .25 .3 .35 .4 .45 .5 .55 .6 .65 .7 .75 .8 .85 .9 .95 1
    I imagine you meant xla(-0.75(.05)1) but even that is a lot of labels.

    Comment


    • #3
      Hi, Nick, I rewrite the xlabel() option to
      HTML Code:
      xlabel(-0.75(0.5)1, labsize(small))
      which places a reasonable number of labels, but the xlabel remains the same

      Comment


      • #4
        Please post a reproducible example that demonstrates your problem. See section 12 in the FAQ for additional advice.

        The commands below were tested in Stata 13 and draw the requested labels on the x-axis.
        Code:
        sysuse auto, clear
        scatter mpg weight, xlabel(1500(500)5000) name(g1)
        scatter mpg weight, xlabel(1500(100)5000) name(g2)
        scatter mpg weight, xlabel(1500(10)5000) name(g3)
        scatter mpg weight, xlabel(1500(1)5000) name(g4)
        scatter mpg weight, xlabel(1500(.1)5000) name(g5)
        Edit: Your twoway command in post #1 has the option xlabel(minmax) at the end. This option overrides the earlier xlabel() option. You can see the effect in the command below.
        Code:
        scatter mpg weight, xlabel(1500(.1)5000) xlabel(minmax)
        Edit 2: Eric wrote the same while I edited my post.
        Last edited by Friedrich Huebler; 27 Feb 2016, 07:09.

        Comment


        • #5
          You introduce two xlabel options in the following order:
          xlabel(-7.5(0.05)1.0, labsize(small)) and
          xlabel(minmax)
          The second overrides the first.
          Compare:
          Code:
          scatter mpg weight, xlabel(1500(500)5000)
          with
          Code:
          scatter mpg weight, xlabel(1500(500)5000) xlabel(minmax)
          using the same data set as Friedrich Huebler above (#4)

          Comment

          Working...
          X