Announcement

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

  • [Twoway Graph] Adjusting location of the lines when ylabel is not working

    I am trying to draw a twoway graph using employment data by Industry. Diffz contains the employment values while CZtime indicates the timing of the data. As the outcome graph doesn't sit in the middle of the graph, I added ylabel option based on the values on diffz, but the location of the lines are still the same as before (please see 'with ylabel.gph'). Does anyone know how I can fix it? I dropped all the missing values on diffz as well.

    Code:

    twoway (line diffz CZtime if naics==44) (line diffz CZtime if naics==48) (line diffz CZtime if naics==42) (line diffz CZtime if naics==31) (line diffz CZtime if naics==52), xlabel(-3(1)3) legend(label(1 "Retail Trade") label(2 "Transportation & Warehousing") label(3 "Whole Sale") label(4 "Manufacturing") label(5 "Finance and Insurance")) title("Industry Change by County", size(medium)) ytitle("Employment", size(medium)) ylabel(-100(20)100)
    Attached Files

  • #2
    FAQ 12.4 states

    12.4 Posting image attachments: please do use .png



    Stata graphs should be posted as .png file attachments (start with the Clipboard icon). Please don't use other file formats, even .gph.

    See next section 12.5 for why other images (e.g. screenshots) are usually much less helpful than you imagine.
    Please do this in your future posts. Here is the graph posted as a .png file.
    Click image for larger version

Name:	graph1.png
Views:	1
Size:	48.0 KB
ID:	1564835




    So it appears that you want to restrict the range of the y-axis. Use the -if- qualifier to do this. Also, having your data in a panel structure (either as is or usingcollapse), you can

    Code:
    xtset naics CZtime
    xtline diffz if diffz<=100 & inlist(naics, 44, 48, 42, 31, 52)
    + comma followed by the other options.

    Comment


    • #3
      Andrew Musau gives excellent advice, particular to read and heed the FAQ.

      Sometimes Stata looks at observations you aren't using -- for a good reason which was once explained to me, except that I have forgotten what it is.

      You may need this brute force approach to get the graph not to cover such a wide range.

      Code:
      preserve 
      
      keep if inlist(naics, 44, 48, 42, 31, 52) 
      
      <your graph command> 
      
      restore 

      Comment

      Working...
      X