Announcement

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

  • My Catplot seems to have broken?

    Hi all,

    Long time reader, first time poster.

    I have just encountered a bizarre error with Catplot. (Note: I am using Stata SE 17).

    Essentially, both new and old code I have used to generate catplots is no longer working. Consistently, I am returned the same nonsensical plot, no matter the syntax or variables in question. I have attached what the output I am getting below.

    It will return this issue from any given attempt at a catplot:
    e.g:
    catplot rep78, by(foreign) percent(foreign) recast(bar)

    Will return only one singular horizontal bar.



    Basically, all was fine yesterday and now today nothing is working. Even stranger it always returns the same single bar frequency.

    As to how this has occurred the only thing I have done today is I experimented with a user made command "catcibar". See here: https://aarondwolf.github.io/catcibar/.

    After installing this error began to occur with my catplot. I promptly uninstalled it, and reinstalled catplot. Neither of these seems to have fixed the problem.

    Any advice is appreciated. I am at a complete loss here. I tried uninstalling and reinstalling my Stata...no dice. I am afraid this person's user made package was borderline Stata-malware.

    Attached Files
    Last edited by Evan Walker; 13 Oct 2024, 16:47.

  • #2
    Evan,

    Possibly running the command:
    Code:
    ado update, update
    Might clean up traces of older, or unneeded files automatically on your system.
    http://publicationslist.org/eric.melse

    Comment


    • #3
      catplot is from SSC. Recently I revised the command and its syntax. https://www.statalist.org/forums/for...tegorical-data

      You appear to be using the previous version, which is fine by me.

      Warning: If you update catplot as suggested by ericmelse you lose a chance of understanding your current problem.

      I agree that the syntax you cite should not produce a graph like that with the auto data.

      I have never used catcibar by Aaron Wolf from GitHub. Long-term members of Statalist may be aware that I am not positive about the kinds of graphs it produces if I understand the help correctly. But that prejudice is only materlal here only for explaining why I am not familiar with the command, Glancing at the code gives me no sense that it could interfere with the operation of catplot.

      Accusing or publicly suspecting any program author of producing "borderline Stata-malware" requires a really strong understanding of their code. Not a nice thing to say.

      I wonder whether your version of the auto dataset has been modified somehow but even so I don't see how you could possibly get that graph with my code. So, my bottom line is that I can't explain your results.

      Some things you could do -- please show the results:

      Code:
      sysuse auto, clear 
      
      describe
      
      su rep78 foreign, detail 
      
      which catplot, all
      
      which catcibar, all

      Comment


      • #4
        Aaron Wolf is a member here although not very active. I am pinging him to notify him of this thread.

        Otherwise without a reply to my previous I have no more information and can add nothing to my puzzlement.

        On a different level, I note that catcibar calculates t-based confidence intervals and so does not cater for binomial, Poisson or any other intervals. Correct me if I am wrong.

        Comment


        • #5
          I recently had exactly the same issue with catplot (from SSC thanks to NickCox) as EvanWalker. That is, I ran code for a catplot in an old Do-file, after updating catplot, and my plot looked just like Evan's, i..e a single category when I was expecting several. I compared the syntax of my old file with that required in the undated catplot and found that I had to change it (Stata/SE 18.0 for windows Revision 4sept 2023).


          This was Old Code - which just produces a single block/category:
          set scheme s1color
          sysuse auto, clear
          tab rep78
          catplot rep78, blabel(bar, pos(base) size(4)) bar(1, bfcolor(none)) ysc(off)
          This is the change i made to the catplot line to get what I expected - and what the code above produced before I updated catplot (i.e. 5 Categories of rep78):
          catplot, over(rep78) blabel(bar, pos(base) size(4)) bar(1, bfcolor(none)) ysc(off)




          Comment


          • #6
            Laurence Lester #6

            Thanks for your contribution, but I am puzzled by this report, although not as much as by #1.

            It's not in question, I trust, that the 2024 version of catplot changed the syntax. The old syntax will work fine if and only if Stata can see the old catplot code.

            A command that perhaps deserves to be better known is discard, which flushes program code that is visible to Stata.

            If you work even a little like me, you may have all sorts of files in different folders or directories on different computers and sometimes need to pay attention to which file is being seen. (The average Stata user may be much tidier than I am in that respect, but there's some method to my madness. I can answer this question because I could find pertinent code.)

            Otherwise I ran your code with the old catplot (2010) and get this, which looks fine to me.

            Code:
            set scheme s1color
            sysuse auto, clear
            tab rep78
            catplot rep78, blabel(bar, pos(base) size(4)) bar(1, bfcolor(none)) ysc(off)
            Click image for larger version

Name:	lester.png
Views:	1
Size:	39.2 KB
ID:	1765980

            Last edited by Nick Cox; 18 Oct 2024, 03:22.

            Comment


            • #7


              HI @Nick Cox & any others who are intersted

              I tried with discard and it made no difference , i.e.
              Code:
              set scheme s1color
              sysuse auto, clear
              discard  
              catplot rep78, blabel(bar, pos(base) size(4)) bar(1, bfcolor(none)) ysc(off)
                  graph save "c:\Temp\Graph1.gph", replace
              catplot, over(rep78) blabel(bar, pos(base) size(4)) bar(1, bfcolor(none)) ysc(off)  
                  graph save "c:\Temp\Graph2.gph", replace
              graph combine "c:\Temp\Graph1.gph" "c:\Temp\Graph2.gph"
              And these are the results (I'm not sure if the graph works - first time I've tried to add one. If not it shows LHS the single block and RHS the correct graph)


              But after this

              Code:
              which catplot, all
              and this:

              C:\STATA18\ado\plus\c\catplot.ado
              *! 3.0.0 NJC 23 September 2024
              *! 2.0.2 NJC 10 December 2010
              *! 1.0.0 NJC 18 February 2003
              I'm thinking that there is something more complicated that I should have done.

              Can you help please?

              Attached Files

              Comment


              • #8
                Laurence Lester #7

                Please see https://www.statalist.org/forums/help#stata for why posting .gph attachments is advised against and why you should post .png attachments.

                Thanks for persevering. You tickled a bug in catplot, which I have fixed privately and will submit to SSC. Some secondary puzzles remain but that is the headline.

                Backing up on the story: I changed the syntax of catplot and announced a new version in https://www.statalist.org/forums/for...tegorical-data

                The new help file is written in terms of the new syntax. The help file doesn't assume that people have seen the announcement. It includes an entire section explaining that the syntax has changed.

                It seems that perhaps you missed the announcement, or did not read it in detail. Or that you just updated the files without studying the help afresh.

                Whatever you did or did not do, the question my side is why would applying the old syntax to the new command produce any result at all, let alone such a bizarre one.

                The answer is a bug in your terms, and in mine. A capture prefix on the syntax statement early in the file -- something I introduced while rewriting the program -- just ignored your syntax, which was wrong -- and limped through to produce a graph, that isn't what you want and which is nothing even close.

                The file should start

                Code:
                *! 3.0.1 NJC 19 October 2024 
                *! 3.0.0 NJC 23 September 2024
                *! 2.0.2 NJC 10 December 2010
                * 2.0.1 NJC 18 May 2010
                * 2.0.0 NJC 28 May 2010
                * 1.1.2 NJC 11 February 2004
                * 1.1.1 NJC 2 February 2004
                * 1.1.0 NJC 8 January 2004
                * 1.0.1 NJC 29 April 2003
                *! 1.0.0 NJC 18 February 2003
                program catplot
                    version 8
                    
                    syntax [if] [in] [fweight aweight iweight/] ///
                    , OVER1(str asis) [PERCent(varlist) PERCent2 FRaction(varlist) FRaction2   ///
                    YTItle(str asis) OVER2(str asis) by(str asis) recast(str) * ]

                The first line doesn't affect performance, but is a signal to future readers. If the first line of your catplot is instead

                Code:
                *! 3.0.0 NJC 23 September 2024
                then you should update. If the first line says something like 3.0.2 or 3.1.0 you shouldn't be bitten by this bug.

                The line starting syntax differs from that in 3.0.0 : the prefix capture has been edited out.

                Now any attempt to use the old syntax with the new version of the command will produce an error message.

                I can now give a better story for Evan Walker who started this thread, but has not re-appeared.

                Evan presumably installed the new version of catplot and also applied the old syntax without seeing (or without understanding) the Statalist post and without studying the help file carefully.

                This must have happened before Evan noticed the problem reported in #1 and then reinstalled catplot 3.0.0. That is, Evan must have installed catplot 3.0.0 at least twice, Applying the same code twice or more would have the same effect.

                As said in #2 there is no reason to suppose that installing catcibar from GitHub would or could have had any effect on catplot.

                So, the old syntax for catplot won't work with the new catplot, but the consequence of trying that should have been an error message.

                Thanks again for what turned out to be a bug report.
                Last edited by Nick Cox; 19 Oct 2024, 01:32.

                Comment


                • #9
                  Thanks to Kit Baum as always, a revised ado file is now up on SSC.

                  Comment


                  • #10
                    Originally posted by Nick Cox View Post
                    Laurence Lester #7

                    Please see https://www.statalist.org/forums/help#stata for why posting .gph attachments is advised against and why you should post .png attachments.

                    Thanks for persevering. You tickled a bug in catplot, which I have fixed privately and will submit to SSC. Some secondary puzzles remain but that is the headline.

                    Backing up on the story: I changed the syntax of catplot and announced a new version in https://www.statalist.org/forums/for...tegorical-data

                    The new help file is written in terms of the new syntax. The help file doesn't assume that people have seen the announcement. It includes an entire section explaining that the syntax has changed.

                    It seems that perhaps you missed the announcement, or did not read it in detail. Or that you just updated the files without studying the help afresh.

                    Whatever you did or did not do, the question my side is why would applying the old syntax to the new command produce any result at all, let alone such a bizarre one.

                    The answer is a bug in your terms, and in mine. A capture prefix on the syntax statement early in the file -- something I introduced while rewriting the program -- just ignored your syntax, which was wrong -- and limped through to produce a graph, that isn't what you want and which is nothing even close.

                    The file should start

                    Code:
                    *! 3.0.1 NJC 19 October 2024 
                    *! 3.0.0 NJC 23 September 2024
                    *! 2.0.2 NJC 10 December 2010
                    * 2.0.1 NJC 18 May 2010
                    * 2.0.0 NJC 28 May 2010
                    * 1.1.2 NJC 11 February 2004
                    * 1.1.1 NJC 2 February 2004
                    * 1.1.0 NJC 8 January 2004
                    * 1.0.1 NJC 29 April 2003
                    *! 1.0.0 NJC 18 February 2003
                    program catplot
                    version 8
                    
                    syntax [if] [in] [fweight aweight iweight/] ///
                    , OVER1(str asis) [PERCent(varlist) PERCent2 FRaction(varlist) FRaction2 ///
                    YTItle(str asis) OVER2(str asis) by(str asis) recast(str) * ]

                    The first line doesn't affect performance, but is a signal to future readers. If the first line of your catplot is instead

                    Code:
                    *! 3.0.0 NJC 23 September 2024
                    then you should update. If the first line says something like 3.0.2 or 3.1.0 you shouldn't be bitten by this bug.

                    The line starting syntax differs from that in 3.0.0 : the prefix capture has been edited out.

                    Now any attempt to use the old syntax with the new version of the command will produce an error message.

                    I can now give a better story for Evan Walker who started this thread, but has not re-appeared.

                    Evan presumably installed the new version of catplot and also applied the old syntax without seeing (or without understanding) the Statalist post and without studying the help file carefully.

                    This must have happened before Evan noticed the problem reported in #1 and then reinstalled catplot 3.0.0. That is, Evan must have installed catplot 3.0.0 at least twice, Applying the same code twice or more would have the same effect.

                    As said in #2 there is no reason to suppose that installing catcibar from GitHub would or could have had any effect on catplot.

                    So, the old syntax for catplot won't work with the new catplot, but the consequence of trying that should have been an error message.

                    Thanks again for what turned out to be a bug report.
                    Thank you as always Nick! All does seem to be working now, what had happened matches your last hypothesis posted here on the 19th.

                    Happy as always that old reliable is working again, nothing caused more panic on a Sunday afternoon when I initially bumped into this. I apologize to Aaron Wolf, who got on what we thought may have been a bug there rapidly, and caused nothing but more confusion about catcibar...which evidently is NOT the issue at all. I apologize for some histrionics. At the time the new version of catplot released, we had been at a conference! Your explainer here may also be useful for some other colleagues who bumped into the same issue over the last week!

                    Big thanks all!









                    Comment


                    • #11
                      Evan Walker Thanks for coming back and indeed again for raising the issue!

                      Comment

                      Working...
                      X