Announcement

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

  • How to move x-axis from y=-0.8 to y=0?

    Dear all,

    Now I plot a twoway graph.I want to move the x-axis to zero.Here is my codes and graph.I find that in the graph x-axis begins from y=-0.8.The second graph is which I want(x-axis from y=0).
    Code:
    twoway (connected coef_all1 period) (connected coef_matched1 period, lpattern(dash)) (rcap ci_all1 ci_all2 period) (connected num_treat1 period, lpattern(dot) yaxis(2)), xlabel(-4(1)4) ylabel(-0.08(0.02)0.14,angle(h)) ylabel(-400(200)400,axis(2) grid) legend(off) yscale(off axis(2)) scheme(s1mono)

    Anyone can give me some suggestions?Thanks in anvance.

    Best
    Raymond
    Attached Files
    Best regards.

    Raymond Zhang
    Stata 17.0,MP

  • #2
    You can add a line in the background at zero with an extra option

    Code:
    yline(0) 
    and you can tune its colour and width with documented suboptions: see

    Code:
    help added line options
    However, Stata makes it really hard for you to mess up your graph by putting axis labels inside the graph, where they may -- and in the illustrated case do -- interfere with your data points. For that inclination, I recommend the default in MS Excel.

    You don't give a data example. Please see FAQ Advice #12 on giving data examples.

    Your code is hard to read too. This would be easier to read:

    Code:
    twoway (connected coef_all1 period)                           ///
           (connected coef_matched1 period, lpattern(dash))       ///
           (rcap ci_all1 ci_all2 period)                          ///
           (connected num_treat1 period, lpattern(dot) yaxis(2)), ///
           xlabel(-4(1)4) ylabel(-0.08(0.02)0.14,angle(h))        ///
           ylabel(-400(200)400,axis(2) grid) legend(off) yscale(off axis(2)) scheme(s1mono)

    Comment

    Working...
    X