Announcement

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

  • Title on second y-axis when using by-option

    Hi,

    Any suggestions on how to put a title on the second y-axis when combining multiple y-axes with the by-option?

    Code:
    sysuse auto, clear
    twoway (scatter price rep78, yaxis(1)) (scatter mpg rep78, yaxis(2)), by(foreign) ytitle("title1", axis(1)) ytitle("title2", axis(2))
    There are no problems if I delete by(foreign).

    Thanks

  • #2
    Requesting individual y-titles results in two left-hand side y titles. There is a workaround to this which entails contracting the graph margin so that the first left-hand title is not visible. Otherwise, just turn off the defaults and refer to

    Code:
    help title_options
    For your example,

    Code:
    sysuse auto, clear
    twoway (scatter price rep78, ytitle("title1", size(medium))) ///
    (scatter mpg rep78, yaxis(2) ytitle("title2", size(medium) axis(2))), ///
    by(foreign, note("") iytitle graphr(m(l-8 r-4))) scheme(s1color)


    Click image for larger version

Name:	Graph.png
Views:	1
Size:	26.2 KB
ID:	1540269

    Comment


    • #3
      Originally posted by Andrew Musau View Post
      Requesting individual y-titles results in two left-hand side y titles. There is a workaround to this which entails contracting the graph margin so that the first left-hand title is not visible. Otherwise, just turn off the defaults and refer to

      Code:
      help title_options
      For your example,

      Code:
      sysuse auto, clear
      twoway (scatter price rep78, ytitle("title1", size(medium))) ///
      (scatter mpg rep78, yaxis(2) ytitle("title2", size(medium) axis(2))), ///
      by(foreign, note("") iytitle graphr(m(l-8 r-4))) scheme(s1color)


      [ATTACH=CONFIG]n1540269[/ATTACH]
      Excellent! Thank you!

      Comment

      Working...
      X