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

  • Problem implementing twoway parea in v15.1 in Windows - Patterns no longer appear

    This is my first post, so please forgive/correct any protocol lapses.

    I would like to thank the author of twoway parea, Sergiy Radyakin, for his brilliant work toward making Stata more useful for publication. Notwithstanding Edward Tufte's advice to avoid patterns, those of us who are not journal editors cannot exactly dictate journal policy regarding figures, and must at times resort to patterns when preparing manuscripts.

    Unfortunately, in v15.1 using Windows I can't seem to get twoway parea to work. I tried uninstalling/re-installing, and tried moving the accompanying style file around to see if I might luck out. I even tried it on my work machine, which is also running v15.1 in Windows.

    I used the commands suggested in the help file:

    sysuse auto
    twoway parea l w, sort pattern(pattern6)

    I tried varying the pattern, to no avail, and tried different schemes. I didn't find any other entries on this forum that had solved this for v15.x (though I did see another user who failed to get it to work on this version, but it seems it wasn't resolved).

    Does anyone have any other ideas?

    I would very much appreciate any insight the group might be able to provide.

  • #2
    Welcome to Statalist. Please recall to specify the source (download location) of user-written commands in the future, in case anyone is interested in installing the program. Sergiy Radyakin is active in the forum, so he will likely look into your problem in detail. If you have successfully used this program with previous versions of Stata, you can always use version control.

    version 14
    sysuse auto
    twoway parea l w, sort pattern(pattern6)


    • #3
      As a clarification, the source of Sergiy's user-submitted ado is from ssc, as in ssc install twoway_parea, replace

      If it helps, I also tried the following code:

      version 14: twoway parea l w, sort pattern(pattern6)

      version 13: twoway parea l w, sort pattern(pattern6)

      version 12: twoway parea l w, sort pattern(pattern6)


      • #4
        Welcome to Statalist.

        You write that twoway parea does not work. After some experimentation I have come to realize that you meant it runs with no errors, but does not produce the patterned output it promises. In particular, when I installed twoway_parea from SSC (ssc describe twoway_parea) I also installed and ran it, producing the following output, which does not demonstrate any variation in the pattern as one would expect.

        Using version control as suggested in post #2 (presumably under the assumption that when you wrote that it does not work, you meant it would not run, not that it would run but produce incorrect output) does not solve the problem. I am running Stata 15.1 on macOS, so it's apparently a general problem.

        To improve your future posts, reducing the risk of being misunderstood, please take the time to review the Statalist FAQ linked to from the top of the page, as well as from the Advice on Posting link on the page you used to create your post. Note especially sections 9-12 on how to best pose your question.

        Section 12.1 is particularly pertinent

        12.1 What to say about your commands and your problem

        Say exactly what you typed and exactly what Stata typed (or did) in response. N.B. exactly!
        Never say just that something "doesn't work" or "didn't work", but explain precisely in what sense you didn't get what you wanted.
        The more you help others understand your problem, the more likely others are to be able to help you solve your problem.

        Click image for larger version

Name:	parea2.png
Views:	1
Size:	85.9 KB
ID:	1475788
        Last edited by William Lisowski; 20 Dec 2018, 14:52.


        • #5
          William, thank you for your helpful suggestions to better describe in what sense the program is not working. In retrospect, instead of saying it didn't work, I should have specifically explained that it didn't perform its unique function, meaning, the reason it was written in the first place.

          The unique function of this program is to allow the use of patterns in an area graph, which I also should have made clear.

          When I run the program, it does not produce the patterns as intended. Instead, it produces the same kind of graph that would have been produced by twoway area instead of twoway parea, where the area is solid, rather than pattern6 or any pattern other than a solid pattern.
          Attached Files


          • #6
            I'm not optimistic we're going to have any luck unless and until Sergly can help. The output of help twoway parea tells us

            It uses some undocumented features of Stata to enable pattern fills
            which suggests to me that even Sergly may not be able to help with this.

            I'm afraid the most viable option may be the one suggested in the last post on the previous thread you found at


            which was to save the graph as a PDF or EPS and the edit it with a vector graphics editor, of which Adobe Illustrator is the canonical example, but for which open source (that is, free) alternatives are available.


            • #7
              I’m not sure the command ever worked for the MacOS. I think I saw something about it being a Windows specific command since it is related to the graphics processing engine used by the OS. This might be a good case to raise to Stata tech support to see if the problem is happening at a much lower level than the ado program itself.


              • #8
                As an update, I have found a work around.

                If you still have Stata v14, it still works* with that version running as a separately-installed program (see graphic below).

                Admittedly, it is ugly. I am also a fan of Edward Tufte and hate that some of my target journals require patterns; alas, Edward Tufte is not the senior editor for any of the journals I submit to.

                As best as I can tell, it does not work* if you have upgraded to Stata 15.1. Furthermore, it does not seem to work* by using the version 14: prefix.

                I suspect the problem lies in a failure to make Stata backwards compatible with prior versions, but would certainly like to know about other possibilities. I don't think it failed* because I retained v14 on my computer, because that wouldn't explain why it failed* on my work computer.

                Fortunately, there is good news for those who publish their work. The simple solution would be to not upgrade to v15.1 or keep your version 14.

                I am still hoping that Sergiy Radyakinor someone else might be able to figure out how to use this in Stata 15.1.

                If this is a defect in backwards compatibility, is there a simple way to forward this thread to Stata to ask them to kindly investigate?

                Alternatively, does anyone feel that that would be futile because official Stata doesn't want people using their product to publish graphs in high-impact journals that do not comport with their reportedly strong sense of style, taste, and preference?

                To summarize, if no solution is forthcoming, I respectfully submit that those who need patterned fills to publish might want to avoid upgrading to Stata 15.1, or at the very least, retain a copy of Stata 14.

                Thanks to all who gave advice and insight on this.

                *work in the sense of performing the fundamental function it was designed to perform, namely, to allow users to render area as a pattern rather than a solid. This is important for users who publish in certain journals (including the high-tier medical journals), but don't want to switch to Excel or another low-functioning program to render their camera-ready graphs.

                Click image for larger version

Name:	Graph_With_Pattern.png
Views:	1
Size:	117.5 KB
ID:	1475898


                • #9
                  I suspect the problem lies in a failure to make Stata backwards compatible with prior versions,
                  No, the failure lies in the code's dependence on undocumented features of Stata, as I quoted from the help file in post #6. Stata is exemplary at backwards compatibility for its documented features—such as implementing "version control" to allow the use of old syntax in newer versions. When a software developer fails to document a feature, developers who learn of it make use of it at their own risk.

                  is there a simple way to forward this thread to Stata to ask them to kindly investigate?
                  Copy the URL for this topic into an email addressed to Stata Technical Services, as described at


                  • #10
                    What do you notice that is different between Stata 14 and Stata 15 with regards to graphics? A: alpha layer transparency. The reason why alpha transparency wasn’t implemented sooner was due to the underlying graphics engine.

                    This isnt necessarily about maintaining or breaking backwards compatibility since all Stata commands still function properly. It is, like William Lisowski mentioned, a challenge with relying on undocumented commands/functionality for which there is no promise of backwards compatibility. The command still works with Stata 14 because Stata 14 uses a different graphics engine.


                    • #11
                      Dear Rich,

                      thank you for bringing this up to my attention. As W.Lisowski and W.Buchanan have mentioned, twoway_parea relies on the undocumented capabilities of Stata. I have clearly written this in the description of the twoway_parea. The program was written in 2007-2008 (still at the times of Stata 9) and the fact that it worked for 10 years is evidence of remarkable stability of Stata's internal structure and dedication to backward compatibility.

                      But (as others have mentioned) reliance on undocumented features leaves the functioning of this code at the mercy of the StataCorp. Should they decide to no longer provide this undocumented capability or outright prohibit it, there is nothing that can be done in my code. As with other input-output commands (notably saving data), adding "version X" that you've tried doesn't really help as it controls the ado-code, not the underlying low-level internals of the graphic engine.

                      Notably, the pattern fills were implemented by StataCorp's graphics code and subsequently disabled/hidden in dialogs, options and config files in the released versions. To this day I don't know whether this was:
                      • work in progress that was never finished, or
                      • something that was suppressed because it was not working on all the platforms where Stata runs,
                      • or it was suppressed by graphics design considerations (think Tufte).
                      My code hasn't changed, and I confirm that it continues to run in Stata 14 for Windows and I confirm that it doesn't run in Stata 15 for Windows. This means that something has changed in Stata's code or configuration leaving twoway_parea dysfunctional. This has been reported by Stephen Okiya earlier in this thread though at the time we've blamed it on the color schemas.

                      At the moment I see two possibilities:
                      1) the engine has changed dramatically, and the patterns are no longer possible. I very subjectively and without proper grounding deem this as low probability.
                      2) the engine has changed, but remains supportive of the patterns, although additional steps are now required to make them functional.

                      I believe #2 has higher probability, but in the absence of any example (recall that this is an undocumented capability) it is impossible [=prohibitively costly] for me to figure this out on my own without a hint from the StataCorp.

                      Those of you who worked with parea before noticed that while you can control one color of the pattern (as shown e.g. on slide 10 here) the other color always remained bluishgrey, since my attempts to set it were never successful, but it was sufficient for my work. Taking a completely wild guess, (based solely on the absence of error messages regarding patterns), I believe the other color is now being set by Stata to the same color as the foreground line color, so the patterns continue to work, but interleave two same colors, resulting in a solid fill. If this is the case, then the fix may be rather simple. Otherwise we can safely retire twoway_parea after 10 years (and 6 Stata versions) of service.

                      The command VennDiagram that relies on twoway_parea may be adjusted to use colors by default in Stata 15+ to provide a meaningful image as discussed here.

                      Those seeking patterns in their illustrations and shy of R may look at gnuplot.

                      Sincerely, Sergiy Radyakin


                      • #12
                        In Stata 15 on Windows, the default graph render is changed from gdi to Direct 2d to support color transparency. It somehow broke Sergiy's twoway_parea code. By the way, which is unintentional and I am looking into it. Meanwhile, the old render is still available although undocumented. To enable it, type

                        set graph_render gdi
                         sysuse auto
                        twoway parea l w, sort pattern(pattern6)
                        should give fill pattern back.

                        After, use

                        set graph_render default
                        to set Stata back to the default render.
                        Last edited by Hua Peng (StataCorp); 27 Dec 2018, 07:39.


                        • #13
                          I highly recommend you NOT use set graph_renderer gdi unless you really need to draw a graph with the legacy graphics engine as that feature may not be available in future versions of Stata. In addition, the GDI graphics engine does not support many of Stata's new graphics features so you may get unexpected results when drawing some graphs.
                          Last edited by Chinh Nguyen (StataCorp); 27 Dec 2018, 08:32.
                          -Chinh Nguyen


                          • #14
                            Dear Hua Peng and Chinh Nguyen,

                            thank you very much for looking into this and the advice you provided.
                            Once again, your commitment to backward compatibility in Stata is truly remarkable!

                            I have checked with the recommended render setting in Stata 15.1 for Windows and the graph is produced fine. The patterns are missing in some of the output formats:
                            -- present: EMF, PNG, TIFF
                            -- partially absent: WMF (present in legend keys, not in plot region)
                            -- absent: SVG, PDF

                            The same problems were with earlier versions of Stata (just checked with 14). I have not checked the other formats (postscript).

                            Thank you very much and happy holidays! Sergiy.


                            • #15
                              Thank you all for your insights. This is an interesting discussion, and Hua Peng, thank you for the workaround staying in v15, though I understand that the ability to conform to journal requirements could be lost at any time, this being an unsupported feature.

                              Hua Peng and Chinh Nguyen, because of the precarious nature of this feature, I wonder if this could be elevated as a program feature. Might it be worth integrating patterns into Stata proper, so as not to hold users back from featuring Stata graphs in their publications?

                              The frustration arises because Stata is so very useful, it is disappointing that I can't showcase my Stata graphs in high-tier journals. Stata is such an important part of my work, it is a shame to have to go back to something like MS Excel if I am fortunate enough to get into a top journal in my field. This seems like a giant step backwards.

                              In any case, thank you for looking into this, and in the mean time, providing a workaround. : )