Announcement

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

  • make room for labels on -bar- or -hbar-?

    I have been trying to sort this out for too long; I'm sure it's somewhere in the archives, but I can't hit upon the correct search terms, as I usually end up with thousands of unrelated hits.

    I'm making a simple bar graph

    graph hbar (count) id, over(group)

    The variable -group- has labels that are about 15 chars, and I'd like to use them. However, only the last 2-3 characters appear - the rest is truncated. How to make the left margin wider?

    I looked at other -hbar- graphs I have made, and they all seemed to do the right thing without my intervention.

    thanks,
    Jeph

  • #2
    Apologies for the duplicate, the first post gave an error - I checked and didn't see it posted, so I posted again. And again too, maybe.

    Comment


    • #3
      This refers to new syntax introduced in the update to Stata 13 on 9 October 2014 (thus plugging much of the gap for which catplot (SSC) has been one solution for the last decade).

      I can't reproduce this. The following syntax works fine for me.

      Code:
      sysuse auto
      graph hbar (count), over(foreign)
      label def origin 0 "made in United States" 1 "made elsewhere and so foreign", modify
      graph hbar (count), over(foreign)
      EDIT: This isn't what you're asking. I think I don't understand the new syntax yet.
      Last edited by Nick Cox; 05 Nov 2014, 12:51.

      Comment


      • #4
        Your example Nick is spot on, and in fact works fine for me. But in my particular data, all I see of the labels are the last two characters:
        E3.pdf


        Comment


        • #5
          I believe you, but we need something reproducible to discuss.

          Comment


          • #6
            Okay, I managed to reproduce it using some synthetic data. Turns out the issue occurs only if the labels have inverted commas in them.


            Code:
            clear all
            set obs 5
            gen group = _n
            label define group 1 "This is a very 'long' label" 2 "This is also a 'long' label" 3 "Not so long" 4 "Somewhere in between" 5 "Shortest"
            label values group group
            expand group
            gen id=_n
            tab group
            graph hbar (count) id, over(group)
            Obviously, I can remove the single quotes, but would be much nicer if I could include.

            Comment


            • #7
              Confirmed. I think you found a bug. I'd email StataCorp tech support, catplot (SSC) does not seem to be a work-around in so far as it depends on graph hbar, which I think is broken for your kind of input.

              Comment


              • #8
                Thanks for the post . I ran into the same issue. Once the single quotes ' were removed, graph hbar ran fine.

                Comment

                Working...
                X