Announcement

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

  • Bug? Graph theme in Stata 15 vs Stata 14 - Unwanted outline appears around bar outline

    Using the same scheme in Stata 14 and Stata 15 results in histograms that look slightly different, and the behaviour in 15 is unwanted.
    The code is simple:

    Code:
    sysuse auto
    hist mpg

    In 14 we see:

    Click image for larger version

Name:	cap14.PNG
Views:	1
Size:	9.6 KB
ID:	1399925


    In 15 we see:
    Click image for larger version

Name:	cap15.PNG
Views:	1
Size:	15.3 KB
ID:	1399926


    There are very thin lines around the bars. The outline colour has been set to white, but there appears to another outline around the outline! This is unwanted.


    This line is also only partially shown when exporting to emf.

    Click image for larger version

Name:	CaptureH.PNG
Views:	1
Size:	10.6 KB
ID:	1399924


    Is this the place to report this bug? Or have I missed an option that will do away with this extra outline, while preserving the white outline that I want.


    Thanks,
    James

  • #2
    I have a thought as to what's going on but I want to view the image in a drawing application to confirm my theory.
    Last edited by Chinh Nguyen (StataCorp); 30 Jun 2017, 10:41.
    -Chinh Nguyen

    Comment


    • #3
      The look you're going for can be achieved by using the barwidth() option:

      Code:
      hist mpg, color("0 128 255") barwidth(3.5)

      Click image for larger version

Name:	hist.png
Views:	1
Size:	14.4 KB
ID:	1399954


      But let's discuss what's going on when you use different outline and fill colors. What you're seeing is the result of a change we made to how outlines are rendered. Prior to Stata 15, outlines were drawn with what's known as a center stroke alignment. Stata 15 now uses an inside stroke alignment. Here's a good illustration of the different stroke alignments:

      Click image for larger version

Name:	th03fig30.jpg
Views:	1
Size:	28.0 KB
ID:	1399952


      For a center stroke, half of the outline is inside the object and the other half is outside of it. For an inside stroke, the outline is inside of the object. For an outside stroke, the outline is outside of the object.

      We switched from center to inside stroke alignment because there were a couple of problems with a center stroke alignment. The first being that objects can turn out bigger than what's requested. For example, if you draw a circle that's 10 x 10 pixels and you draw a 2 pixel outline around it, the visual size of the circle is now 12 x 12 (half of the outline is inside the circle, the other half is outside the circle). The second problem with using a center stroke is if you use transparency with both the outline and fill, you'll get a darker color only where the outline and fill overlap. The following image is of a red circle that has its outline and fill at 50% opacity.
      Click image for larger version

Name:	strokeandfill.png
Views:	1
Size:	47.7 KB
ID:	1399953


      The circle appears to be bigger than what was requested and there's a transparent ring on the outside.

      The following image is of a red circle that has its outline and fill at 50% opacity but with an inside stroke.

      Click image for larger version

Name:	strokeandfill2.png
Views:	1
Size:	47.3 KB
ID:	1399955

      The circle is visually true to size but you do get a dark ring where the outline and fill overlap.

      Unfortunately, the Windows, Mac, and Unix graphics renderers only support a center stroke. To simulate an inside stroke, Stata recalculates the size of the outline so that it is rendered at the same visual size of the fill. But a combination of lack of precision when rendering to the screen and antialiasing of two different colors (in your case a blue fill and a white outline on top of it) can sometimes result in visual artifacts.

      We've been working on a solution that will be available in a future update (as well as some other features we couldn't finish in time for the release) that'll allow you to control how outlines are drawn. This will also solve the problem with rendering maps that's mentioned in another thread. You typically won't need to worry about how outlines are drawn but will have more control over them if you need to customize the appearance of your graphs.
      -Chinh Nguyen

      Comment

      Working...
      X