Announcement

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

  • Is it possible to avoid the extra outline that appears outside the outline in graphs generated in Stata 15 and above?

    I would like to plot stacked bars with white outlines in Stata 18, but I have not been able to do it without having an extra outline showing up.

    This outermost border is very thin yet noticeable (how clearly you see it depends on the colors used in the fill and the border, and the format used to export the plot).

    Here's an example (run using Windows):

    Code:
    sysuse auto.dta
    
    graph bar, over(foreign) asyvar stack bar(1, lwidth(vthick) lcolor(white)) bar(2, lwidth(vthick) lcolor(white)) xsize(3)
    Click image for larger version

Name:	graph_bar.png
Views:	1
Size:	9.4 KB
ID:	1722120


    If my reading of this previous topic is correct, this is an unintended consequence of drawing outlines using inside stroke alignment, as adopted since Stata 15. The proposed workaround for histograms is to space out the bars conveniently. Unfortunately, that does not solve the problem with stacked bars.

    Would there be an alternative approach to avoid the extra lines in stacked bars?

  • #2
    Have you tried using the graph editor, clicking on the problem area and exploring parameters to change it?

    Comment


    • #3
      Try

      Code:
      sysuse auto.dta
      
      graph bar, over(foreign) asyvar stack bar(1, lwidth(vthick) lcolor(none)) bar(2, lwidth(vthick) lcolor(none)) xsize(3)
      instead of trying to match the background color.

      Comment


      • #4
        Hi Andrew, thank you for the suggestion.

        lcolor(none) indeed removes all outlines.

        That could also be achieved by omitting the line options altogether.

        Code:
        sysuse auto.dta
        
        graph bar, over(foreign) asyvar stack xsize(3)
        However, if possible, I would like to plot the stacked bars with the white outlines.

        Comment


        • #5
          Place the outline outside.

          Code:
          sysuse auto, clear
          graph bar, over(foreign) asyvar stack bar(1, lwidth(vthick) lcolor(white) lalign(outside)) bar(2, lwidth(vthick) lcolor(white) lalign(outside)) xsize(3)

          Comment


          • #6
            That works! Thank you

            Comment

            Working...
            X