Announcement

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

  • marginsplot with custom labels

    Hi,

    I saw a discussion about this topic here: https://www.statalist.org/forums/for...-custom-labels

    I am trying to ask the question there but it seems nobody saw it.

    I have a related question about custom label with marginsplot.

    I am trying to set up something like this to shorten the display of the label:

    marginsplot, recast(line) recastci(rarea) ytitle("Cardiovascular Risk Index") ///
    xtitle("Longtidinal Obesity") xlabel (`=none' "none" `=obese@adulthd' "@adult" `obese@early-adlt' "@early-adult" `=obese@adolsct' "@adolescent")

    But it did not work. Do you know how I can fix it? BTW, how can I make the label to be fully shown but not cut-off

    Of course, there is another option. I could re-define the value label. But I would like to try changing the label in the graph first.

    Thanks!

    Alice
    Attached Files

  • #2
    I am trying to ask the question there but it seems nobody saw it.
    What is more probable is that absent a data example and the margins command that you used to create the figure, there is little that anyone can do from imagination. You will increase your chances of getting a helpful reply if you comply with the FAQ recommendations.

    Comment


    • #3
      As Andrew Musau pointed out, example data is strongly encouraged. That said, if the axis labels are coming value labels take look at Nick Winter & Ben Jann's -splitvallabels- (ssc desc splitvallabels). Also, you can extend the axis length using the xscale(range()) options. For example:

      Code:
      sysuse auto
      label define rep78 1 "Very low rating in 1978" ///
       2 "Mediocre - Low Rating in 1978" ///
       3 "Medium Rating in 1978" ///
       4 "Not bad rating in 1978, considering" ///
       5 "Excellent in 1978--the best of the year!"
      label values rep78 rep78
      reg price rep
      splitvallabels rep78 , length(11)
      global lab = r(relabel)
      margins , at(rep =(1(1)5))
      marginsplot, xlabel($lab) xscale(range(5.25)) name(gr1,replace)
      marginsplot, xlabel($lab)  name(gr2,replace)

      Comment


      • #4
        Scott,

        Thanks for giving me the example of extending the axis. I'll take a look at Winter and Jann's splitvallabels. This is helpful.

        Alice

        Comment

        Working...
        X