Announcement

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

  • Opening a saved .gph with graph use command fails

    Dear Stata users,

    I am using graph twoway command to draw several graphs with multiple graphs in one plot. I then use graph combine to combine all the graphs into one and I also save this graph.

    When I try to open the graph saved via graph combine, it does not open and I get the error "**.gph invalid name".

    Quite surprising, when I try to open the same graph in a different instance of Stata, it does open so there is no doubt if its a stata graph or not.

    Does anyone know why Stata is behaving this way? Is there another way of opening a saved .gph file?


    Thanks for your help.

    Victoria



  • #2
    Welcome to Statalist.

    The advice Marcos gave you on your subsequent topic applies here as well. Without seeing the command you used to save the combined graph, and what Stata told you as a result, and the command you used to open the saved graph, and what Stata told you as a result, it is difficult to narrow the possibilities.

    Please 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 posts. 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!
    The more you help others understand your problem, the more likely others are to be able to help you solve your problem.

    Comment


    • #3
      Thank you Wilson.

      This is the code I use to combine the graphs

      /*Combine the graphs*/
      #delimit ;
      graph combine `graphs' //<========================= macro with the graphs to combine
      ,
      rows(1)
      imargin(`gmargins')
      saving(fplot_test.gph, replace)
      name(fplot_test, replace)
      ;
      #delimit cr


      I try to display the plotted graph with gr use and the output is as follows


      . graph use fplot_test.gph, name(fplot_test, replace)
      file not a Stata .gph file
      r(610);

      If I open the same graph in another new instance of stata it does open
      Now,

      graph use fplot_test.gph, name(fplot_test, replace)

      displays the attached graph.

      why is this happening and is there a solution?

      Thanks,
      Victoria

      Attached Files

      Comment


      • #4
        I believe that instead of using graph use to display the graph you have just saved to disk, you should use graph display fplot_test, since the graph is already in memory.

        I believe that Stata is running your graph use command before your operating system has completed writing the saved graph to disk. That's a guess, but in any event, there is no need for graph use.

        Comment


        • #5
          I already tried that and obtained the following error

          . graph display fplot_test.gph
          fplot_test.gph invalid name
          r(198);


          Is it even possible that stata starts to execute the graph use before completing the task to save the graph on disk? The tasks are executed sequentially, right?

          Comment


          • #6
            You tried
            Code:
            . graph display fplot_test.gph
            but that is the file name of the disk file containing your graph, and Stata has told you that is not a valid name for a graph.

            The name of the graph in Stata's memory is fplot_test (from your name() option), and the command I suggested was
            Code:
            . graph display fplot_test
            Stata "completes" the task to save the graph to disk, in that it passes the data to be written to the operating system, and then instructs the operating system to close the file. But we have seen instances on Statalist where - especially when the file is being written to a network drive - the operating system returns control to Stata before the tasks are complete. Stata works sequentially, but the operating system may work in parallel.

            Comment


            • #7
              I had already tried that in vain also.

              To be more clear, I get the error below and a blank plot is displayed

              . graph display fplot_test
              unrecognized command
              r(199);


              Comment


              • #8
                The graph display command cannot have caused the "unrecognized command" error that you reported in post #7. Post #5 shows that you can run graph display.

                Please read again William's advice in the first response to your question and post complete code that can be reproduced by others instead of the fragments that you have shared so far. Here is an example:
                Code:
                sysuse auto, clear
                scatter mpg weight, name(g1, replace) nodraw
                graph display g1

                Comment

                Working...
                X