Announcement

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

  • Remove empty spaces in the graph.

    Dear All, I run the code (data are available upon request):
    Code:
    #delimit ;
    separate henry, by(year) veryshortlabel;
    tw (line henry202? etime, sort) (line henry2022 etime if etime>=0, lc(green) sort) (scatter henry etime if etime==34, ms(none) mlab(year) xtitle("") leg(off) xlabel(-30(10)40) ylabel(0(2)8) xline(0, lp(dash_dot)));
    graph save "Graph" "NG-F1-henry.gph", replace;
    #delimit cr
    
    #delimit ;
    separate ttf, by(year) veryshortlabel;
    tw (line ttf202? etime, leg(off) sort) (line ttf2022 etime if etime>=0, leg(off) lc(green) sort) 
    (scatter ttf etime if etime==34, ms(none) mlab(year) xtitle("") leg(off) xlabel(-30(10)40) ylabel(0(20)80) xline(0, lp(dash_dot)));
    graph save "Graph" "NG-F1-ttf.gph", replace;
    #delimit cr
    
    #delimit ;
    separate nbp, by(year) veryshortlabel;
    tw (line nbp202? etime, leg(off) sort) (line nbp2022 etime if etime>=0, leg(off) lc(green) sort) 
    (scatter nbp etime if etime==34, ms(none) mlab(year) xtitle("") leg(off) xlabel(-30(10)40) ylabel(0(20)80) xline(0, lp(dash_dot)));
    graph save "Graph" "NG-F1-nbp.gph", replace;
    #delimit cr
    
    #delimit ;
    separate jkm, by(year) veryshortlabel;
    tw (line jkm202? etime, leg(off) sort) (line jkm2022 etime if etime>=0, leg(off) lc(green) sort) 
    (scatter jkm etime if etime==34, ms(none) mlab(year) xtitle("") leg(off) xlabel(-30(10)40) ylabel(0(20)60) xline(0, lp(dash_dot)));
    graph save "Graph" "NG-F1-jkm.gph", replace;
    #delimit cr
        
    graph combine NG-F1-henry.gph NG-F1-ttf.gph NG-F1-nbp.gph NG-F1-jkm.gph, col(2) iscale(1)
    graph save "Graph" "NG-F1.gph", replace
    graph export "NG-F1.pdf", as(pdf) name("Graph") replace
    and obtain the following figure

    Click image for larger version

Name:	NG-F1.png
Views:	1
Size:	95.8 KB
ID:	1695585


    I'd like to make the figure more visible, and wonder if I can remove the empty spaces as much as possible? Thanks.
    Ho-Chuan (River) Huang
    Stata 19.0, MP(4)

  • #2
    You could reduce empty space slightly by spelling out your preferred ylabel() choices.

    Comment


    • #3
      Dear Nick, I do not quite follow you. The is the data set
      Code:
      * Example generated by -dataex-. For more info, type help dataex
      clear
      input float(year etime) double(henry ttf nbp jkm)
      2020 -34 2.12  3.98  4.11  5.25
      2020 -33 2.13  4.26  4.38  5.38
      2020 -32 2.14  4.04  4.09  5.32
      2020 -31 2.16  3.91  3.99   5.3
      2020 -30 2.14  3.91  3.99  5.31
      2020 -29 2.17  3.97     4   5.3
      2020 -28  2.2   3.9  4.03   5.3
      2020 -27 2.18  3.94  4.09   5.3
      2020 -26 2.19  3.69  3.81   5.3
      2020 -25 2.12  3.66  3.82  5.29
      2020 -24 2.08  3.64  3.78  4.18
      2020 -23    2  3.56  3.67  4.13
      2020 -22  1.9  3.51  3.63  4.08
      2020 -21 1.91   3.4  3.52  4.02
      2020 -20 1.93  3.38  3.52     4
      2020 -19 1.89  3.38  3.58     4
      2020 -18  1.9   3.4  3.58     4
      2020 -17 1.93  3.48  3.69     4
      2020 -16 1.88  3.28  3.45   3.9
      2020 -15 1.83  3.19  3.37  3.88
      2020 -14 1.84  3.19  3.22  4.02
      2020 -13 1.82  2.99  2.98  3.73
      2020 -12 1.87  3.04  3.01   3.7
      2020 -11 1.86  3.01  2.98   3.6
      2020 -10 1.86  2.95  2.92  3.56
      2020  -9 1.86  2.92  2.86  3.57
      2020  -8 1.77  2.77  2.69  3.52
      2020  -7 1.84  2.79  2.72  3.52
      2020  -6 1.83  2.83  2.68  3.52
      2020  -5 1.84  2.83  2.78  3.52
      2020  -4 1.98  2.98   2.9  2.98
      2020  -3 1.96  3.03  2.98     3
      2020  -2 1.92  3.04  2.98  2.98
      2020  -1 1.91     3  2.95     3
      2020   0 1.83  2.88  2.92  2.88
      2020   1 1.85  2.87  2.94   2.9
      2020   2 1.82  2.89  2.99     3
      2020   3 1.75  2.84  2.95  2.98
      2020   4 1.68  2.87  2.81  2.96
      2020   5 1.76  2.91  2.92  3.05
      2020   6  1.8  3.01  2.93  3.08
      2020   7 1.83  2.92  2.84  3.08
      2020   8 1.77  2.91  2.89  3.08
      2020   9 1.71  2.87  2.85  3.12
      2020  10 1.78   2.9  2.86   3.1
      2020  11 1.94     3     3  3.12
      2020  12 1.88  3.11  3.08  3.13
      2020  13 1.84  3.05  3.03  3.14
      2020  14 1.87  3.03  2.98  3.14
      2020  15 1.82  2.85  2.79   3.4
      2020  16 1.73  2.73   2.7  3.46
      2020  17  1.6  2.64  2.55   3.4
      2020  18 1.65  2.71  2.69   3.4
      2020  19  1.6  2.61  2.58  3.43
      2020  20  1.6  2.49   2.5  3.25
      2020  21 1.65   2.5  2.52  3.15
      2020  22 1.66  2.46  2.45  2.96
      2020  23 1.64  2.44  2.37  2.98
      2020  24 1.63  2.33  2.29  2.98
      2020  25 1.69  2.23  2.09  2.88
      2020  26 1.64  2.22  2.05  2.88
      2020  27 1.59  2.19     2  2.87
      2020  28 1.55  2.21  2.02  2.86
      2020  29 1.62  2.19  1.96  2.85
      2020  30 1.73  2.31   2.1  2.85
      2020  31 1.85  2.33   2.1  2.81
      2020  32 1.78  2.31   2.1  2.81
      2020  33 1.73  2.33  2.08  2.81
      2020  34 1.72  2.33  2.11  2.81
      2021 -34  2.7  6.49  7.36 15.11
      2021 -33 2.72  6.33  7.27 15.55
      2021 -32 2.73  6.94  7.92 17.25
      2021 -31  2.7  7.23  8.34 17.25
      2021 -30 2.75  7.89   9.2  19.7
      2021 -29 2.75  9.33 10.44  19.7
      2021 -28 2.73  7.67  9.28 18.57
      2021 -27 2.67  7.59  8.57 18.57
      2021 -26 2.74  7.16  8.01 18.31
      2021 -25 2.55  7.23  7.88  8.52
      2021 -24 2.54  7.19  7.76  9.02
      2021 -23 2.49  7.15  7.72  8.48
      2021 -22 2.45  7.67  8.24  8.86
      2021 -21  2.6  7.17  7.71  8.61
      2021 -20 2.66  6.96   7.5  8.56
      2021 -19 2.76  6.98  7.45  8.62
      2021 -18 2.66  7.26  8.05  8.85
      2021 -17 2.56  7.07   7.2  8.87
      2021 -16 2.85  6.43  6.51  8.52
      2021 -15 2.85  6.44  6.59  8.43
      2021 -14 2.79  6.29  6.39  8.37
      2021 -13 2.94  6.37  6.45  8.34
      2021 -12 2.86  6.49  6.62  8.38
      2021 -11 2.88  7.13  7.14  8.43
      2021 -10 2.84  6.76  6.95   8.3
      2021  -9 2.91   6.6  6.56  8.28
      2021  -8 2.87  6.18  6.19  8.27
      2021  -7 2.91  6.26  6.28  8.26
      2021  -6 3.13  5.94  6.03  6.35
      2021  -5 3.22  5.84  5.79   6.3
      2021  -4 3.08  6.13  6.21   6.6
      2021  -3 3.07  5.89   5.9   6.4
      2021  -2 2.95  5.68  5.61  6.25
      2021  -1 2.88  5.79   5.8  6.23
      2021   0 2.85  5.82  5.77  6.04
      2021   1 2.78  5.67  5.65   5.8
      2021   2 2.77  5.59  5.54   6.2
      2021   3 2.78  5.69  5.69  5.92
      2021   4 2.84  5.62  5.63  5.88
      2021   5 2.82   5.5  5.46  5.88
      2021   6 2.75  5.63  5.53     6
      2021   7  2.7  5.72  5.72     6
      2021   8 2.66  5.62  5.65     6
      2021   9 2.66   5.9  5.96  6.01
      2021  10 2.69  6.15  6.28     6
      2021  11 2.67  6.36  6.46  6.05
      2021  12  2.6  6.46  6.62  6.07
      2021  13 2.48  6.27  6.24  6.08
      2021  14 2.56  6.17  6.05  6.53
      2021  15 2.53  6.28   6.3  6.65
      2021  16 2.48  6.21  6.08  6.57
      2021  17 2.54  6.02  6.04  6.42
      2021  18 2.58  6.31  6.35  6.62
      2021  19 2.51   6.4  6.42  6.86
      2021  20 2.52  6.45  6.49  6.86
      2021  21 2.57  6.35  6.47  6.75
      2021  22 2.56  6.46  6.71  6.93
      2021  23 2.59  6.36  6.43  6.87
      2021  24 2.62  6.41  6.64  6.93
      2021  25 2.61  6.55  6.44  7.02
      2021  26 2.64  6.61  6.51  6.92
      2021  27 2.51  6.64  6.56  6.92
      2021  28 2.46  6.87  6.72  6.97
      2021  29 2.52  6.73   6.6  6.98
      2021  30 2.52  6.63  6.51  6.99
      2021  31 2.53  6.61  6.49  6.99
      2021  32 2.56  6.86  6.75     7
      2021  33 2.62  6.83  6.71  7.01
      2021  34 2.62  6.91  6.79  7.01
      2022 -34 3.88 30.43 30.31 34.19
      2022 -33 3.81 31.97  31.8 34.07
      2022 -32 3.92 29.35 29.17 33.95
      2022 -31 4.08 28.09 27.92 33.27
      2022 -30 4.25 26.19 25.88 32.92
      2022 -29 4.86 25.17 24.63    33
      2022 -28 4.27 28.72 28.15 32.61
      2022 -27 4.26 29.17 28.47 32.85
      2022 -26 4.28 26.06 25.47 22.94
      2022 -25 4.03 25.16 24.63 21.14
      2022 -24  3.8 25.02 24.46 20.53
      2022 -23    4 26.28 25.55 22.09
      2022 -22 4.03 30.84 30.25 25.19
      2022 -21 4.05 30.94 30.38 26.01
      2022 -20 4.28 30.38 29.61 25.83
      2022 -19 6.27 30.18 29.46 25.28
      2022 -18 4.64 29.51 28.93 26.81
      2022 -17 4.87 30.06 29.48 24.71
      2022 -16 4.75 25.14 24.41 23.71
      2022 -15  5.5 25.64 24.94  24.2
      2022 -14 4.89 26.87 26.23 24.34
      2022 -13 4.57 27.75 27.12 25.35
      2022 -12 4.23 26.73 26.22  25.1
      2022 -11 4.25  25.9  25.2 25.31
      2022 -10 4.01 24.95 24.31 24.72
      2022  -9 3.96 25.02 24.25  24.8
      2022  -8 3.94  25.9 25.28 24.57
      2022  -7  4.2  26.8 26.08 24.89
      2022  -6 4.31 23.63  23.1 24.82
      2022  -5 4.72 23.27 22.66 23.08
      2022  -4 4.49 24.98 24.47 24.51
      2022  -3 4.43 24.54 23.97 23.81
      2022  -2  4.5 26.53 25.96 25.96
      2022  -1 4.62 29.52 28.92 28.97
      2022   0 4.57 43.78 42.74  37.1
      2022   1 4.47 38.09 38.73 27.51
      2022   2  4.4 32.53 31.92 27.95
      2022   3 4.57 39.81 38.72  31.5
      2022   4 4.76 53.78 52.46 38.51
      2022   5 4.72 52.23 51.23  43.6
      2022   6 5.02 61.75 60.84 38.65
      2022   7 4.83 72.53 70.86 51.77
      2022   8 4.53  68.5 67.03 42.62
      2022   9 4.53 50.33 49.13 38.97
      2022  10 4.63 40.88 38.97 38.33
      2022  11 4.73 42.24  40.7 37.15
      2022  12 4.66 36.85 35.39 37.25
      2022  13 4.57 37.21 35.86 37.45
      2022  14 4.75 33.19 31.55 33.64
      2022  15 4.99 34.17 32.77 35.56
      2022  16 4.86    34 32.34  35.5
      2022  17  4.9  31.2 29.74 34.81
      2022  18 5.19 31.96 30.95 34.18
      2022  19 5.23 37.68 36.62 34.12
      2022  20  5.4    36 34.94 34.68
      2022  21 5.57 32.73 31.24 34.43
      2022  22 5.51 33.01 32.15 33.97
      2022  23 5.34  35.3  34.6 33.88
      2022  24 5.61 34.69 33.89 34.15
      2022  25 5.64 34.69 33.89 35.44
      2022  26 5.72 36.34 33.72 34.69
      2022  27 5.71 35.36    32 32.95
      2022  28 6.36 33.49  30.5  33.1
      2022  29 6.28 33.16 29.72 33.61
      2022  30 6.64 32.02 27.77 33.02
      2022  31 6.68 32.62 27.52 32.97
      2022  32    7 33.53 27.78 32.93
      2022  33  7.3 30.24 23.12 32.93
      2022  34 7.82 30.28 23.07 25.37
      end
      There are four figures in the graph. I meant if the empty spaces, say, between top left and bottom left figures can be removed. Any suggestions? Thanks.
      Ho-Chuan (River) Huang
      Stata 19.0, MP(4)

      Comment


      • #4
        graph combine has more options to do that.

        Comment


        • #5
          Thanks, Nick. I find the "imargin(tiny)" option.

          Ho-Chuan (River) Huang
          Stata 19.0, MP(4)

          Comment

          Working...
          X