Announcement

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

  • How to define the legend position deep inside the chart?

    I'm generating a few maps with use of spamp (SSC) that I'm subsequently merging with use of grc1leg (SSC) into the graphic below:
    Click image for larger version

Name:	Screen Shot 2014-09-18 at 13.27.43.png
Views:	1
Size:	64.1 KB
ID:	242112
    With use of the code below:
    Code:
    grc1leg  `plots', cols(2) ring(0) position(5) name(maps, replace)
    I would like to move the legend into the chart below the map for 2008. My thinking was that ring(0) defines the position inside the chart, maybe this is the case but still I would like to move my map further into the chart.
    Kind regards,
    Konrad
    Version: Stata/IC 13.1

  • #2
    Try position(0)

    Comment


    • #3
      Well, it placed legend in the middle of the chart. I would like to place it under second map. Does ring take only values 0/1?

      Click image for larger version

Name:	Screen Shot 2014-09-18 at 16.32.40.png
Views:	1
Size:	63.2 KB
ID:	242529
      Kind regards,
      Konrad
      Version: Stata/IC 13.1

      Comment


      • #4
        [G] legend_options shows how it can be done without grc1leg (not tested):

        Another location suboption is provided for use with by(): at(#). You specify this option to tell
        by() to place the legend inside the R x C array it creates:
        Code:
        . scatter mpg weight || lfit mpg weight ||,
        legend(cols(1))
        by(foreign, total legend(at(4) pos(0)))

        Comment


        • #5
          Hi Svend,

          Thanks for your comments, I got option at() not allowed when added at() to my grc1leg syntax. I think, I'll have to accept present results. I've to use grc1leg as I'm trying to avoid drawing 4 identical legends.
          Kind regards,
          Konrad
          Version: Stata/IC 13.1

          Comment


          • #6
            I think you can get what you want with the bmargin() option for the legend, which controls the outer margin (i.e., the margin beyond the box around the legend). With the right (determined by experimentation) bottom and right margin, you can slide the legend into position. Something like this:


            Code:
            sysuse auto
            gr twoway scatter mpg price weight, name(g1) legend(bmargin(0 20 20 0) col(1))
            grc1leg g1 g1 g1, ring(0) pos(5)

            Comment


            • #7
              Did you find a solution?

              I have exactly the same problem, that I cannot get the ledgend at the right position (I also have 3 graphs and want the position 4 or 5 (down right corner) to be used as a legend.)

              Comment


              • #8
                I had the same problem. However I tried the suggestion of Nicholas Winter above and it worked for me. The bmargin command carries over. If you alter the position in the original graph it will also be altered in the combine graph.

                Code:
                twoway (line protest_high year, lpattern(-))(line protest_low year) if year>1989, xlab(1990(5)2015) scheme(s1mono) legend(cols(1) rows(2) bmargin(0 20 20 0))
                grc1legwby panel1.gph panel2.gph panel3.gph, row(2) legendfrom(panel1.gph) position(5) ring(0) scheme(s1mono)

                Comment

                Working...
                X