Announcement

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

  • Saving graphs

    Hi

    I don't know if anyone else has had this issue, but I found that the 'saving( )' option in the twoway command seems to work differently (and not as well) to the graph export command. I'm using Stata/MP 14.2 on a Mac.

    Below are two examples of using these two alternative ways of saving a series of two-way graphs for a set of variables. Using the 'saving( )' option in the twoway command, Preview could not open the files when the .png or .tif extensions were used. This was a problem with the file format. However, when the graph export command was used, Preview could open the graph file.

    Example 1:


    foreach i of local continvars {
    twoway (scatter monthchg `i') (lfit monthchg `i') if (monthchg < .), ///
    legend(order(1 "Observed" 2 "Fitted")) scheme(s1mono) ///
    saving(graph_monthchg_`i'.png, replace)
    }


    Example 2:

    foreach i of local continvars {
    twoway (scatter monthchg `i') (lfit monthchg `i') if (monthchg < .), ///
    legend(order(1 "Observed" 2 "Fitted")) scheme(s1mono)
    graph export graph_monthchg_`i'.png, replace
    }




  • #2
    My reading of the help file (help saving_option) is that this is intentional: The saving() option only saves a Stata graph, while graph export allows you to save the graph in other formats like .png.
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      Thanks Maarten

      Comment


      • #4
        Hello,
        I am trying to make a graph.
        If I use the graph tab, how can I save the commands in a do file?
        Thank you for your help
        Lucia floris

        Comment


        • #5
          floris Lucia I don't understand. Please post your code and explain what you want to do from there.

          Comment


          • #6
            Originally posted by floris Lucia View Post
            Hello,
            I am trying to make a graph.
            If I use the graph tab, how can I save the commands in a do file?
            Thank you for your help
            Lucia floris
            I think I understand what you are saying. When we use the graph editor and makes edits to the graphs, the actions cannot be tracked in the logged to be saved in the do file. I know I have always wanted to drop/update the log rank p in the K-M plots at the specified location with every new analyses I do with appended data. Perhaps that is what you mean floris? I am really curious to see what the group moderators have to say for this question.

            Comment


            • #7
              This is a common question, something to the tune of "How do I save my graph editor commands."

              My answer is that "It's possible, but I do not recommend it." Why? It necessitates that you use Stata's graph recorder feature. And while that's fine, now you've another layer of complexity to your work- now, the do file you've written isn't the thing that made your graph, it's the do-file code and another file that made your graph. Which is fine, but in my personal opinion, you should never use the graph editor unless you absolutely have to. Stata's existing graphical tools are awesome as it is, and you can make all kinds of good looking graphics with a little know-how, I assure you.

              Comment


              • #8
                Originally posted by Jared Greathouse View Post
                This is a common question, something to the tune of "How do I save my graph editor commands."

                My answer is that "It's possible, but I do not recommend it." Why? It necessitates that you use Stata's graph recorder feature. And while that's fine, now you've another layer of complexity to your work- now, the do file you've written isn't the thing that made your graph, it's the do-file code and another file that made your graph. Which is fine, but in my personal opinion, you should never use the graph editor unless you absolutely have to. Stata's existing graphical tools are awesome as it is, and you can make all kinds of good looking graphics with a little know-how, I assure you.
                Thanks Jared Greathouse I mostly end up using the graph editor in the end since I am lazy to invest the time to look up for the right set of options in the graph help. Will keep at it and see if I can do away with using the graph editor. It does make me waste a lot of time on a repeated basis.

                Comment


                • #9
                  Hello,
                  I am on my way to retirement. I occasionally use Stata for calculations. I have an old version of Stata 12 IC. To present graphs in a publication, I would like to present the results with Stata. Unfortunately, I realise that I am unable to do this. Could you tell me if there are people who do this type of work for a fee? (2 graphes)

                  Thank you very much for your kind information.
                  Lucia Floris

                  Comment


                  • #10
                    You want to pay people money to make two graphs? Before we go paying people to make anything, let's back up for a moment.

                    What kinda graphs are we talking about? What graphs are you interested in making? floris Lucia

                    Comment


                    • #11
                      Hello,
                      I've been trying to make my graphs for a week now and I haven't made much progress.
                      I'm not doing very well.
                      Sincerely
                      Lucia

                      Comment


                      • #12
                        Here is my work after one week
                        lucia
                        Attached Files

                        Comment


                        • #13
                          And there are two others in the same style that I haven't started: (
                          Lucia

                          Comment


                          • #14
                            I can't see the picture. My question for you however still remains: you want to make two graphs. What kinds of graphs? floris Lucia . Bar graphs? Line graphs? What exactly do you want made?



                            EDIT: Now that I look at the picture, this can easily be cleaned up. Look at this
                            Code:
                            sysuse auto, clear
                            version 12: graph hbar (mean) foreign, blabel(bar, format(%6.3f)) yti("Percentage Cars that are Foreign")
                            Of course there's more I could do here if I wanted to, but what I'd advise you to do is save your money.

                            Download the dataex command via ssc inst dataex, replace and type it into your Stata terminal, and then we can get to the bottom of this.
                            Last edited by Jared Greathouse; 01 May 2022, 18:12.

                            Comment


                            • #15
                              Your graph looks very much like what Nick discussed in: https://www.stata-journal.com/articl...article=gr0034
                              ---------------------------------
                              Maarten L. Buis
                              University of Konstanz
                              Department of history and sociology
                              box 40
                              78457 Konstanz
                              Germany
                              http://www.maartenbuis.nl
                              ---------------------------------

                              Comment

                              Working...
                              X