Announcement

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

  • twoway bar graphs

    Hi, I would like to begin by saying that I am new to statalist, so apologies for any issues with the quality of my question.basically i have two variables simple gvc participation and complex gvc participation.i want to plot them for each country in the form of two bars.i have 40 countries.i hope this won't take too much of your time.thanks in advance


  • #2
    Thanks for the apologies but giving your real name and giving a data example would match our requests in the FAQ Advice at #6 and #12 in https://www.statalist.org/forums/help I can't imagine a good reason why not giving a data example can be thought to improve your question or why being new should make you feel you shouldn't read and follow advice about asking questions.

    I don't know what gvc participation is. It's possible that explaining that would lead to better advice.

    twoway bar is not a good start for your problem. You will want to show the country names which is possible with twoway bar but not as easy as with graph hbar.

    Running this nonsense example in your Stata

    Code:
    sysuse auto, clear
    graph hbar (asis) turn trunk in 1/40, over(make)
    graph dot (asis) turn trunk in 1/40, over(make)
    will underline some key points about your problem.

    You will be pushed to get a good graph if you put country names anywhere except horizontally.

    40 named entities is a challenge here.

    Dot charts are likely to work better than bar charts here.

    You can fool around with xsize() and ysize() options to use more space. I don't show that in the code.

    I have to guess that your best option is two groups of 20.


    Code:
    keep in 1/40
    sort turn trunk
    gen which = _n > 20
    graph dot (asis) turn trunk, over(make, sort(1)) by(which, note("")) nofill subtitle("", pos(9) nobexpand fcolor(none))
    My best guess at what you should do is to decide on the best sort order. It won't predictably be country name. Let's suppose it's sorting on complex.

    Code:
    sort complex 
    gen which = _n > 20 
    graph dot (asis) simple complex, over(country, sort(2)) by(which, note("")) nofill subtitle("", pos(9) nobexpand fcolor(none))
    The trickery here is using a by() option to plot two groups side by side but then suppressing the evidence that you did that. More on the strategy at https://journals.sagepub.com/doi/pdf...36867X20976341

    I can't make better guesses without seeing the data.

    Comment

    Working...
    X