Announcement

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

  • "better looking" bar?

    Dear All, I have data
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int(year kb78etrica kb01jep)
    1994   41   .
    1995   36   .
    1996   35   .
    1997   56   .
    1998   60   .
    1999   67   .
    2000   82   .
    2001  106   .
    2002  123  32
    2003  142  50
    2004  182  64
    2005  268 123
    2006  325 191
    2007  343 282
    2008  468 384
    2009  532 511
    2010  581 589
    2011  625 597
    2012  737 720
    2013  821 761
    2014  890 830
    2015  937 897
    2016 1103 928
    2017 1058 947
    2018 1039 928
    end
    command
    Code:
    twoway (bar kb78etrica year) (bar kb01jep year)
    with graph
    Click image for larger version

Name:	q.png
Views:	1
Size:	19.4 KB
ID:	1484111

    My question is: Is there any way to make this graph "better looking" (in any sense)?
    Ho-Chuan (River) Huang
    Stata 17.0, MP(4)

  • #2
    Use variable labels that are informative.

    Remove the xtitle() "year". Who needs it?

    xla(1994(4)2018) would use the space better.

    Use less intense colours.

    I'd consider putting the legend inside the graph at top left with col(1) ring(0) pos(11)

    Some other details within these suggestions:

    Code:
    label var kb78etrica "whatever" 
    label var kb01jep "whichever" 
    set scheme s1color 
    twoway bar kb78etrica kb01jep year, xtitle("") xla(1994(4)2018) /// 
    blcolor(red blue) bfcolor(red*0.2 blue*0.2) legend(col(1) pos(11) ring(0)) yla(0(250)1000, ang(h)) 
    
    twoway bar kb78etrica kb01jep year, xtitle("") xla(1994(4)2018) /// 
    blcolor(red blue) bfcolor(red*0.2 blue*0.2) legend(off) yaxis(1 2) ///
    ytitle("whatever", color(red) axis(1)) yla(0(250)1000, ang(h) axis(1))  ///
    ytitle("whichever", color(blue) axis(2)) yla(0(250)1000, ang(h) axis(2))


    Click image for larger version

Name:	river_1.png
Views:	1
Size:	22.2 KB
ID:	1484113


    Click image for larger version

Name:	river_2.png
Views:	1
Size:	23.8 KB
ID:	1484114

    Comment


    • #3
      Dear Nick, This is great. Thanks a lot.
      Ho-Chuan (River) Huang
      Stata 17.0, MP(4)

      Comment


      • #4
        I just noticed that 2010 is an anomaly. You need transparency too to show all values in all years, unless you change to e.g. a line chart.

        Comment


        • #5
          Dear Nick, Thanks for this extra suggestion. I am not familiar with graph options. Where can I find the option to add transparency?
          Ho-Chuan (River) Huang
          Stata 17.0, MP(4)

          Comment


          • #6
            -----------------------------------------------------------------------------------------------------------------
            search for transparency (manual: [R] search)
            -----------------------------------------------------------------------------------------------------------------

            Search of official help files, FAQs, Examples, SJs, and STBs

            [G-4] colorstyle . . . . . . . . . . . . . . . . . . . . Choices for color
            (help colorstyle)

            Video . . . . . . . . . . . . . . . Preview: Transparency in Stata 15 graphs
            6/17 http://www.youtube.com/watch?v=2bK-WZAcGMo
            See how to reveal more about your data with transparency
            in Stata's graphs.

            Comment


            • #7
              Dear Nick, Thanks. I will see what I can do.
              Ho-Chuan (River) Huang
              Stata 17.0, MP(4)

              Comment


              • #8
                Dear Nick, Is this what meant by "transparency"?
                Click image for larger version

Name:	transparency.png
Views:	1
Size:	50.7 KB
ID:	1484250
                with data
                Code:
                * Example generated by -dataex-. To install: ssc install dataex
                clear
                input int(year kb78etrica kh01jep)
                1994   41   .
                1995   36   .
                1996   35   .
                1997   56   .
                1998   60   .
                1999   67   .
                2000   82   .
                2001  106   .
                2002  123  32
                2003  142  50
                2004  182  64
                2005  268 123
                2006  325 191
                2007  343 282
                2008  468 384
                2009  532 511
                2010  581 589
                2011  625 597
                2012  737 720
                2013  821 761
                2014  890 830
                2015  937 897
                2016 1103 928
                2017 1058 947
                2018 1039 928
                end
                I obtained that by graph editor (after running the part of your code) because I have no idea which part of the help colorstyle wull get me there? Could you kindly give some explicit suggestions? Thanks.
                Ho-Chuan (River) Huang
                Stata 17.0, MP(4)

                Comment


                • #9
                  I am puzzled at why you found the documentation given unclear, but you got the main idea. Here is a syntax example.

                  Code:
                  * Example generated by -dataex-. To install: ssc install dataex
                  clear
                  input int(year kb78etrica kb01jep)
                  1994   41   .
                  1995   36   .
                  1996   35   .
                  1997   56   .
                  1998   60   .
                  1999   67   .
                  2000   82   .
                  2001  106   .
                  2002  123  32
                  2003  142  50
                  2004  182  64
                  2005  268 123
                  2006  325 191
                  2007  343 282
                  2008  468 384
                  2009  532 511
                  2010  581 589
                  2011  625 597
                  2012  737 720
                  2013  821 761
                  2014  890 830
                  2015  937 897
                  2016 1103 928
                  2017 1058 947
                  2018 1039 928
                  end
                  
                  label var kb78etrica "whatever" 
                  label var kb01jep "whichever" 
                  set scheme s1color 
                  twoway bar kb78etrica kb01jep year, xtitle("") xla(1994(4)2018) /// 
                  blcolor(red blue) bfcolor(red*0.2%20 blue*0.2%20) legend(col(1) pos(11) ring(0)) yla(0(250)1000, ang(h))

                  Comment


                  • #10
                    Dear Nick, Thanks. Now I see the point. This is probably the first time I use the opacity/transparency. Admittedly, I have trouble in understanding the documentation (especially without examples/figures).
                    Ho-Chuan (River) Huang
                    Stata 17.0, MP(4)

                    Comment


                    • #11
                      The video cited in #6 gives examples.

                      Comment


                      • #12
                        Dear Nick, Thanks for the message. I know that there is a recording function when we manually adjust the graph. But, I suppose that there is no similar function like importing an excel file manually and a corresponding command appearing in the results window, say:
                        Code:
                        import excel "raw\Quantile-citation.xlsx", sheet("工作表1") firstrow clear
                        After all, most people are not that familiar with all graph options, and want to include the modification in their code.
                        Ho-Chuan (River) Huang
                        Stata 17.0, MP(4)

                        Comment


                        • #13
                          Please start a new thread with this different question.

                          Comment

                          Working...
                          X