Announcement

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

  • Rotate By/X Axis Labels of slideplot

    Hello,

    I am currently using slideplot to make stacked bar graphs but my current problem is that the category by labels (x axis) run into each other. Below is a quick example

    Code:
    use http://www.stata-press.com/data/r8/voter.dta
    slideplot bar candidat [w=frac], neg(2) pos(3 4) by(inc)
    Which outputs the following graph.
    Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	27.1 KB
ID:	1526392





    In this example, because there are a relatively small amount of categories, the x axis labels don't touch and the graph is easily readable. However, in my other dataset there are a larger amount of categories and the x axis labels blend in to each other. I've looked around and can't seem to figure it out. I've tried using the xlab(,angle(90)) but that doesn't work because I assume the x axis is technically not an x axis and I've also tried label(angle(90)) but that seems to also not be a valid option.

    Ultimately, I would like to output a stacked twoway bar chart and am open to other suggestions, but it seems that, so far, slideplot is the easiest and doesnt require a lot of work calculating boundaries if I could just get this label issue resolved.

    Code:
    use http://www.stata-press.com/data/r8/voter.dta
    catplot candidat inc [w=frac], stack asyvars recast(bar)
    I have also figured out how to do it in catplot but am stuck in the same part of rotating the x axis labels.

    Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	30.6 KB
ID:	1526394
    Last edited by Ben Zhu; 25 Nov 2019, 15:40.

  • #2
    slideplot and catplot are both from SSC, as you are asked to explain (FAQ Advice #12). Both are wrappers for graph bar or graph hbar in your context.

    slideplot dates from 2003 and is little used by me. I think you've stumbled across a limitation in that the by() option is a wrapper for calls to over() options in graph bar but there is no way to pass options as well. I do not have any intentions at this time to revise the program. If I did, I would rewrite it completely as a wrapper for twoway bar.

    If axis labels run into each other, my strong advice is to use horizontal bars so that this does not happen. Otherwise,

    Code:
    use http://www.stata-press.com/data/r8/voter.dta, clear 
    
    catplot candidat inc [w=frac], stack asyvars recast(bar) var2opts(label(ang(v)))
    embodies my next best advice.

    Comment


    • #3
      Thanks so much!

      Comment

      Working...
      X