Announcement

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

  • The graph command corresponds to Graph Editor

    Dear All, According to the following dataset,
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str3 code float(growth lprivo)
    "ARG"   .6176451  2.752746
    "AUS"  1.9751474  4.004016
    "AUT"   2.889185  4.178968
    "BGD"   .7082631 2.6060796
    "BRB"   2.652859  3.704847
    "BEL"  2.6513345 3.2444575
    "BOL"   .3550578 2.5758026
    "BRA"  2.9300966  3.065546
    "CAN"  2.3859885 4.1086454
    "CHL"  1.4469954   3.32541
    "COL"  2.2270143  3.094773
    "CRI"  1.6136966 3.0807066
    "CYP"   5.384184  4.127378
    "DNK"  2.1793702  3.748256
    "DOM"   2.498769 2.9503646
    "ECU"   2.388093  2.889542
    "SLV"  -.6075561 3.1289306
    "FJI"  1.8458964  3.163393
    "FIN"   2.798494  3.947039
    "FRA"   2.431281  4.323712
    "DEU"   2.453688  4.336713
    "GHA"  -.9631622 1.6240644
    "GRC"    3.22405   3.60341
    "GTM"   .9292306  2.589061
    "GUY" -.28062087  3.021234
    "HTI"  -.6579341  2.042972
    "HND"   .5977848 3.1720316
    "ISL"   3.012389 3.5494244
    "IND"   1.915168 2.9719946
    "IRL"   3.254494 3.8947036
    "ISR"   2.810969  3.622525
    "ITA"  2.9329815 4.0790596
    "JAM"   .4177902  3.200545
    "JPN"   4.304759  4.854981
    "KEN"   1.962509 3.1259286
    "KOR"   7.156855 4.1817265
    "LBR"  -.4721583  2.318493
    "MYS"   4.114544 3.8480165
    "MLT"   6.652838 3.7835095
    "MUS"   3.024178 3.1929696
    "MEX"  1.9739418  3.130883
    "NPL"   .7671511  2.044247
    "NLD"  2.2005773 4.4623857
    "NZL"  1.1241318  3.626801
    "NER"  -2.751478  2.568801
    "NOR"   3.182494  4.402111
    "PAK"   2.698163 3.0333946
    "PAN"  2.0271885  3.694385
    "PNG"  1.1203711  3.037085
    "PRY"  2.3819315 2.6755195
    "PER"  .06020596  2.589619
    "PHL"  1.1587406 3.2949524
    "PRT"    3.64731 4.0075636
    "SEN"  -.4378241 3.3143885
    "SLE"  -.3398342 1.6226246
    "ZAF"   .3920211  4.275775
    "ESP"   2.880327  4.175143
    "LKA"  2.7045984 2.7856154
    "SWE"  1.8881342 4.4898977
    "CHE"  1.4218653  4.950846
    "SYR"   2.511772 2.1776114
    "TWN"   6.624734  4.057945
    "THA"   4.876695  3.856032
    "TGO"   .4627753 3.0857854
    "TTO"  1.1207864 3.4465425
    "GBR"  1.9622195  3.835404
    "USA"   1.712265   4.72797
    "URY"  1.0253086 3.0545275
    "VEN"  -.8835508  3.500184
    "ZAR" -2.8119445 1.4072825
    "ZWE"   .8381555  3.137074
    end
    I then use the Graphics - Twoway graph menu to draw the following figure
    Click image for larger version

Name:	g1.png
Views:	1
Size:	113.2 KB
ID:	1446635


    The corresponding command is
    Code:
    twoway (scatter growth lprivo, mlabel(code)) (lfit growth lprivo)
    Then, I use the Graph Editor to change (i.e., hollow circle, and legend off) the above graph to the following graph
    Click image for larger version

Name:	g2.png
Views:	1
Size:	124.7 KB
ID:	1446636


    My question is: how can I get the corresponding command for this graph? Thanks.
    Ho-Chuan (River) Huang
    Stata 17.0, MP(4)

  • #2
    I find that the easiest way is to record what actions you want in the graphics editor and then copy the relevant commands from the resulting .grec file with the prefix gr_edit
    Code:
    StataFileTM:00001:01100:GREC:                          :
    00005:00004:00001:
    *! classname: twowaygraph_g
    *! family: twoway
    *! date: 30 May 2018
    *! time: 11:11:06
    *! graph_scheme: s1color
    *! naturallywhite: 1
    *! end
    
    // File created by Graph Editor Recorder.
    // Edit only if you know what you are doing.
    
    .plotregion1.plot1.style.editstyle marker(symbol(circle_hollow)) editcopy
    // plot1 symbol
    
    // plot1 symbol
    
    
    // <end>


    Code:
    twoway (scatter growth lprivo, mlabel(code)) (lfit growth lprivo)
    gr_edit .plotregion1.plot1.style.editstyle marker(symbol(circle_hollow)) editcopy
    I then normally run these from a do file but it is not essential.
    I hope that this is of some use.

    Martyn

    Comment


    • #3
      Dear Martyn, Many thanks for your suggestion. Unfortunately, I have difficulty in understanding what you meant. Could you kindly explain to me step by step. For example, where can I find the .grec file?
      Ho-Chuan (River) Huang
      Stata 17.0, MP(4)

      Comment


      • #4
        Code:
        twoway (scatter growth lprivo, mlabel(code) msymbol(circle_hollow)) (lfit growth lprivo, leg(off))

        Comment


        • #5
          Dear Andrew, Thanks. In fact, I knew the command you suggested. But, I was thinking if I can do that from Graph Editor (and the recorded commands).
          Ho-Chuan (River) Huang
          Stata 17.0, MP(4)

          Comment


          • #6
            Hello River,

            Start the recording in the graph editor by clicking the red ' start recording' icon and make your modifications to the plot. When you are satisfied with the plot press it again and you have the option to name and save the recording any any location you like, I tend to keep mine in the folder associated with the project. The .grec file is a standard text file and the commands of interest are in the section preceded by
            Code:
            // File created by Graph Editor Recorder.
            // Edit only if you know what you are doing.
            The command string(s) that you need have a prefix of "."
            Code:
            .plotregion1.plot1.style.editstyle marker(symbol(circle_hollow)) editcopy
            When you want to run this command you must add the command gr_edit

            Code:
             
             gr_edit .plotregion1.plot1.style.editstyle marker(symbol(circle_hollow)) editcopy

            I hope that this makes sense.

            Cheers,
            Martyn

            Comment


            • #7
              Look at the instructions in #10 of the following link

              https://www.statalist.org/forums/for...ome-line-graph

              Note: Crossed with Martyn's reply.
              Last edited by Andrew Musau; 30 May 2018, 06:13.

              Comment


              • #8
                Dear Martyn, Many thanks again for your explanation. I will give it a try soon.
                Ho-Chuan (River) Huang
                Stata 17.0, MP(4)

                Comment


                • #9
                  Dear Andrew, Thanks so much for this information. I will give it a try soon.
                  Ho-Chuan (River) Huang
                  Stata 17.0, MP(4)

                  Comment


                  • #10
                    Dear Martyn Sherriff and Andrew Musau, It worked just fine. Thank you again.
                    Ho-Chuan (River) Huang
                    Stata 17.0, MP(4)

                    Comment

                    Working...
                    X