Announcement

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

  • controlling the tables of legends : 3 cols in first row, 1 in second, 3 in third?

    Hi,
    Before I give up on this (for Stata 13.1 MP for unix console), I still ask here: Could one manipulate legends to show a box like this mock example?
    Code:
    1 2 3
      4
    5 6 7
    It's not the end of the world, but as I am plotting 3 lags, the contemporaneous series, and 3 forwards, it would make sense to label them this way, and not
    Code:
    1 2 3
    4 5 6
    7
    Such an option does not seem to be documented, but maybe someone knows a hack.

  • #2
    Code:
    sysuse nlsw88, clear
    graph bar wage if occu<=7, over(occu) asyvar legend(cols(3) hole(4 6))
    Click image for larger version

Name:	legend7.png
Views:	1
Size:	23.9 KB
ID:	244572

    Comment


    • #3
      Of course, I overlooked this, but it is *documented*. Thanks!

      Comment


      • #4
        Ah, but the holes must be consistent with order of labels specified for the same legend somehow. Meaning that the order must also skip the holes, no? In any case, I got no holes on my attempt when I had to use labels (and thus order).

        Comment


        • #5
          Sergiy gave a good answer to the question. Still, a deeper principle is to lose the legend if you can. The same graph goes better as a legendless dot chart, I suggest.

          Code:
          graph dot wage if occu<=7, over(occu, sort(1) descending)  scheme(s1color) linetype(line) lines(lw(vthin) lc(gs12)) marker(1, mc(orange))

          Click image for larger version

Name:	dot.png
Views:	1
Size:	25.2 KB
ID:	244581

          Comment


          • #6
            I totally agree with Nick. The chart I posted was intended as any example to demonstrate the gaps in the legend. Everything outside the legend is irrelevant and should be ignored by the reader. If Laszlo posted an example of his code running on public data, there would be no such confusion.

            Furthermore, Laszlo is still not satisfied with solution, but neither the code he typed, nor produced result is shown. Only some incompatibility between holes and labels is mentioned. There is no problem to use both options simultaneously, but perhaps that depends on the graph type and other circumstances:

            Click image for larger version

Name:	legend7a.png
Views:	1
Size:	5.8 KB
ID:	244586

            labels first and last applied to corresponding series in this example.

            Code:
            sysuse nlsw88, clear
            graph bar wage if occu<=7, over(occu) asyvar legend(cols(3) hole(4 6) label(1 "first") label(7 "last"))
            Best, Sergiy Radyakin

            Comment


            • #7
              Thanks, Sergiy, Nick.

              I slept on my code, and of course, I simply miscoded how I wanted to generate (!) the numbering for the holes. Once I get it right, I get graphs like this one (for mock data). Which is not very pleasing aesthetically, but I think you'd agree that doing away with the legend makes little sense.

              For posterity: Indeed, you can (should) simply specify legend labels with consecutive numbers, without renumbering them for the holes inserted into the sequence.

              Comment


              • #8
                If you cannot see the inserted picture either, I re-upload a copy here.
                Click image for larger version

Name:	x2_x3.png
Views:	1
Size:	71.3 KB
ID:	245902

                Comment

                Working...
                X