Announcement

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

  • graph legend size

    Hi,

    Is there any option that we can resize a graph legend box? I am using graph combine command, and my legend seems to be larger than what it should be compared to the graph, proportionally speaking.

    Thanks,

  • #2
    Have you looked at

    Code:
    help legend_options
    ?

    Comment


    • #3
      Originally posted by Andrew Musau View Post
      Have you looked at

      Code:
      help legend_options
      ?
      Oh year, I couldn't find anything thou!

      Comment


      • #4
        Code:
        sysuse auto, clear
        set scheme s1mono
        tw (scatter mpg price) (scatter mpg weight), saving(gr1, replace) leg(row(2))
        tw (scatter mpg price) (scatter mpg weight), leg(symy(10) symx(10) textw(10) forces size(tiny) row(2)) saving(gr2, replace)
        gr combine gr1.gph gr2.gph
        Click image for larger version

Name:	Graph.png
Views:	1
Size:	73.4 KB
ID:	1622985


        Last edited by Andrew Musau; 11 Aug 2021, 16:09.

        Comment


        • #5
          Originally posted by Andrew Musau View Post
          Code:
          sysuse auto, clear
          set scheme s1mono
          tw (scatter mpg price) (scatter mpg weight), saving(gr1, replace) leg(row(2))
          tw (scatter mpg price) (scatter mpg weight), leg(symy(10) symx(10) textw(10) forces size(tiny) row(2)) saving(gr2, replace)
          gr combine gr1.gph gr2.gph
          [ATTACH=CONFIG]n1622985[/ATTACH]
          Thank you for your reply. My individual graphs do not have any legend, though, my combined graph has one legend. this line of code, which seems to work perfectly for each individual plot, does not work with the graph combine command!

          Comment


          • #6
            gr combine does not generate a legend. If you are using one of the community-contributed commands, then that is another story. If you can use the -by- option instead of combining graphs, then the options in #4 are valid. See https://journals.sagepub.com/doi/ful...36867X20976341
            Last edited by Andrew Musau; 12 Aug 2021, 01:02.

            Comment


            • #7
              Andrew is doing his best to help you, but without knowing what commands you have issued, this can go on forever or until Andrew's patience runs out (smile).

              Comment


              • #8
                Sure, my codes are a little bit a mess, but having it maybe is better than not having it. Please see the following for the codes:

                Code:
                foreach x in X1 X2 X3 X4 X5 X6 {
                
                margins `x', predict(outcome(0)) saving(file1, replace)
                margins `x', predict(outcome(1)) saving(file2, replace)
                margins `x', predict(outcome(2)) saving(file3, replace)
                
                combomarginsplot file1 file2 file3, ysize(8) xsize(9) legend(rows(1) size(small)) labels("Type1" "Type2" "Type3") name(`x', replace) title("") legend(off) xtitle("")
                
                }
                
                grc1leg X1 X2 X3 X4 X5 X6 , col(2) ysize(20) xsize(10) iscale(0.5) name(all, replace)

                Comment


                • #9
                  append file1-file3, generate a variable identifying the file and use the -by- option of graph. For anything concrete, present a data example of the contents of each of the 3 files using dataex.

                  Comment


                  • #10
                    Beginning with version 2.0, the program -grc1leg2- adds options to scale the legend in a combined graph. The current version can be installed by opening the package description in your viewer:
                    Code:
                    view net describe grc1leg2, from (http://digital.cgdev.org/doc/stata/MO/Misc)
                    and clicking on -(click here to install)-.

                    Comment

                    Working...
                    X