Announcement

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

  • twoway: How to center x-axis title with by() option

    When I create this twoway graph using the by() option, the x-axis title is not centered on the inner plot region (it is centered relative to the whole figure). This does not look good, especially with long value labels on the y-axis. Is there anyway to center the x-title properly?

    Code:
    sysuse auto, clear
    twoway (scatter price weight), ylabel(, angle(horizontal)) by(foreign)
    Click image for larger version

Name:	stata_question.png
Views:	1
Size:	69.4 KB
ID:	1705681



  • #2
    You could manually add the gap if it bothers you that much.

    Code:
    sysuse auto, clear
    twoway (scatter price weight), ylabel(, angle(horizontal)) ///
    by(foreign) xtitle("                 `:var lab weight'")

    Click image for larger version

Name:	Graph.png
Views:	1
Size:	38.6 KB
ID:	1705691


    Comment


    • #3
      Cross-posted at https://stackoverflow.com/questions/...with-by-option

      (I agree: although it's utterly ad hoc, I tend just to add spaces to shunt a title left or right.)

      Comment


      • #4
        Thanks a lot for your answer! If at some point a less ad hoc solution comes up, I would be very interested.

        Comment

        Working...
        X