Announcement

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

  • New addlegend package available from SSC

    Thanks to Kit Baum, a new package called addlegend is available from SSC. To install, type:

    Code:
    . ssc install addlegend, replace
    addlegend is a utility to create a do-it-yourself legend and add it to a twoway graph. In contrast to Stata's legend() option, addlegend can combine multiple symbols in a single legend key. Here's an example:

    Code:
    sysuse auto
    twoway (sc mpg turn, msize(large) ms(Oh)) ///
           (sc mpg turn, msize(large) ms(X) pstyle(p1)) ///
           (lfit mpg turn, pstyle(p2))
    addlegend, y(50) x(105) margin(r=40): ///
           (Oh X) "Mileage (mpg)", msize(large) ///
        || (line) "Fitted values"
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	77.8 KB
ID:	1786359



    See github.com/benjann/addlegend for some further examples.
    ben




  • #2
    The addlegend package has been updated on SSC. Type

    Code:
    . ssc install addlegend, replace
    or use the adoupdate command to install the new version.

    A major change is that the || delimiter between keys is now optional! You may still use it to structure the code, but it is no longer needed. This means that in the above example you could type:

    Code:
    addlegend, y(50) x(105) margin(r=40): ///
        (Oh X) "Mileage (mpg)", msize(large) ///
        (line) "Fitted values"
    Furthermore, note that there are some changes that affect the default behavior. Most importantly, x() now sets the position of the midpoint of a key's symbol instead of the position of the left edge.

    See github.com/benjann/addlegend for a complete list of changes.

    ben

    Comment


    • #3
      Hi Ben, I want to test addlegend a bit for my use case, but I fail to reproduce your examples. I get errors every time.
      See also: https://github.com/benjann/addlegend...sue-4783637822
      Best regards,
      Marc

      Comment


      • #4
        Type -set dp period- and try again. Sorry for that, I'll post an update. (Although I truely believe that it is a big mistake that Stata supports something like -set dp comma-).

        Comment

        Working...
        X