Announcement

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

  • graph export not exporting the window specified in name()

    Dear Statalisters,

    I must be doing something so obviously wrong I don't see it, but when I specify the name() option with graph export, Stata 17 (on Windows 10 Enterprise) seems to be ignoring it and exports the last created graph window or the graph window last clicked on instead. I have access to two versions of Stata 17 and both give me the same results. Here is what I did:
    Code:
    sysuse auto
    graph box price, name(price)
    graph box weight, name(weight)
    graph export price.emf, name(price)
    I even tried
    Code:
    graph export price.emf, name("price"), replace
    graph export price.emf, name(Graph - price) replace
    graph export price.emf, name("Graph - price") replace
    and
    Code:
    set autotabgraphs off
    graph box price, name(price, replace)
    graph box weight, name(weight, replace)
    graph export price.emf, name(price) replace
    Every single time, Stata exports the box plot for weight. Only when I manually click on the box plot for price and return to the main window does
    Code:
    graph export price.emf, name(price)
    actually exports it.

    Am I specifying the name() option incorrectly?

  • #2
    I cannot create .emf graphs using Stata for Mac, but when I do
    Code:
    sysuse auto
    graph box price, name(price)
    graph box weight, name(weight)
    graph export "~/Downloads/price.png", name(price)
    ~/Downloads/price.png contains the box plot for price.

    Perhaps you should try exporting a png and see if that works, in which case the problem may be specific to the emf engine.

    The other thought that comes to mind is that, since you don't specify a path to price.emf, it is being written to whatever your current working directory is, which may not be what you think it is. You might try specifying an explicit path in the export command.

    Comment


    • #3
      I can confirm your issue with the -emf- export. It works with the -png-option.
      My test do-file
      Code:
      sysuse auto, clear
      graph box price, name(price, replace)
      graph box weight, name(weight, replace)
      graph export price.emf, as(emf) name(price) replace
      graph export weight.emf, as(emf) name(weight) replace
      graph export price_png.png, as(png) name(price) replace width(600)
      graph export weight_png.png, as(png) name(weight) replace width(600)
      This really strange because I normally also work with the -emf- export but have not seen the problem. Normally, I directly invole -graph export- after generating the graph.

      So this works:
      Code:
      sysuse auto, clear
      graph box price, name(price, replace)
      graph export price_direct.emf, as(emf) name(price) replace
      graph box weight, name(weight, replace)
      graph export weight.emf, as(emf) name(weight) replace
      graph export price_after.emf, as(emf) name(price) replace
      The -direct- export is correct - the -after- export is wrong. I suggest that you contact Stata Technical Support.

      Comment


      • #4
        Thanks William and Marc. I'm reassured someone else could replicate the issue. I will contact Stata technical support.

        Regarding the file path, I did not specify one in this example but I do in the actual project I'm working on.

        Comment


        • #5
          Originally posted by Maxime Bercholz View Post
          I will contact Stata technical support.
          Have you got news from Stata about this issue?

          Comment


          • #6
            Looks like it is fixed in the new update:
            11. (Windows) graph export with option name() and format EMF exported the topmost graph instead of the named graph. This has been fixed.

            Comment


            • #7
              Originally posted by Marc Kaulisch View Post

              Have you got news from Stata about this issue?
              I did hear back and they said they would likely be able to provide a fix in the next update, which they seem to have done.

              Comment

              Working...
              X