Announcement

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

  • line graph with by() option, suppress yaxis and xaxis on particular graph panels

    I have a line graph using a by variable, and I get a 2x2 panel of graphs as desired. By default certain graphs get an x axis, a y axis, or both. How can I override these defaults and turn off a certain axis, just for one particular panel graph?

    Code:
    webuse grunfeld
    line invest year if inrange(company , 1, 4) , by(company, note("")) xlabel(#3) tline(1930 1940 1950, lcolor(gray*.40)) xtitle("") ytitle("")
    In this example panel 2 has no x axis and no y axis. How can I make panel 1 have no y axis and panel 4 have no xaxis?

  • #2
    Can you use the graph editor to hide individual components. If you record your edits can play them again to recreated you graph. Or through the command window:

    Code:
    webuse grunfeld,clear
    line invest year if inrange(company , 1, 4) , /// 
        by(company, note("")) xlabel(#3) tline(1930 1940 1950, ///
        lcolor(gray*.40)) xtitle("") ytitle("")
    gr_edit plotregion1.yaxis1[1].draw_view.setstyle, style(no)
    gr_edit plotregion1.xaxis1[4].draw_view.setstyle, style(no)

    Comment


    • #3
      When I record how do I see the corresponding code? I pressed the record button, then double clicked on the graph element, made some choices in the dialog box, and clicked OK, but did not see the Stata code appear ... (your code shown works perfectly though, thank you)

      Comment


      • #4
        After you start recording and make changes to the graph press the stop recording button (which is the same as the start recording button) as window will pop up (at least in Windows) "Save graph recording." The resulting file *.grec is just text file that can be viewed in any text editor.

        In this case, the resulting file looks like:

        Code:
        StataFileTM:00001:01100:GREC:                          :
        00004:00004:00001:
        *! classname: bygraph_g
        *! family: by
        *! date: 25 May 2017
        *! time: 13:20:41
        *! graph_scheme: s2colorwhite
        *! naturallywhite: 1
        *! end
        
        // File created by Graph Editor Recorder.
        // Edit only if you know what you are doing.
        
        .plotregion1.yaxis1[1].draw_view.setstyle, style(no)
        // yaxis1[1] edits
        
        .plotregion1.xaxis1[4].draw_view.setstyle, style(no)
        // xaxis1[4] edits
        
        
        // <end>

        Comment


        • #5
          Thank you Scott

          Comment

          Working...
          X