Announcement

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

  • Justification of Label in Legend

    How can I justify (e.g., center, left, right) the labels in a legend of a graph (e.g., line, scatter, etc)? Not the key but the label. I am not providing an example because I want to know how I can justify labels in general and the help file for legends does not provide this information.

  • #2
    Why wouldn't you provide an example?


    Presumably it's possible, but I don't immediately know, though. The guys who would almost certainly know though, is either Ben Jann or Nick Cox

    Comment


    • #3
      I am not providing an example because I want to know if there is an option for legends to specify the justification in general. If I provide an example then I might get answers that just tweak the example and it won't be applicable for other examples. I think it should be possible in general because if you use the graph editor, you can center the labels. I just don't know how you would do it with code.

      Comment


      • #4
        I think this demonstrates what you seek.
        Code:
        sysuse auto, clear
        scatter price weight length, legend(cols(1)) name(default)
        scatter price weight length, legend(cols(1) placement(center)) name(wanted)
        The placement(center) option is a textbox option, and the legend options include the textbox options., and the twoway options include the legend option.

        Comment


        • #5
          Thanks William, that's exactly what I was looking for. Why do we have to use placement and not justification from the textbox options? I used justification(center), but it didn't work.

          Comment


          • #6
            If you open my second example in Graph Editor (your first post implies you are familiar with it) and click on Place, you'll see that the textbox that contains it is exactly as large as the text. So justification makes no difference, the text has no room to move within its textbox. But placement controls the location of the textbox within the area that encompasses it.

            Comment


            • #7
              Got it, thanks!

              Comment


              • #8
                The textbox, the physical thing that contains the area of the text, is distinct from how the text is centered in that box. If I'm understanding correctly, it's possible to have a textbox in position 6, centered, and the text right justified.

                Graphics in Stata (or any language) can be pretty challenging. That's why I respect the folks who go nuts and write their own color schemes and graphics schemes, because writing ado code is already hard enough- using graphics can be tough, writing graphics must be ridiculously challenging in terms of how intimately you must know the inner workings of Stata.

                Comment


                • #9
                  Yeah exactly. And if the box is so small that the alignment of the text within that box doesn't matter, only the alignment of the box can change the actual alignment.

                  Comment

                  Working...
                  X