Announcement

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

  • Consistency between appearance of graphs in window and when exported

    Dear Statalist,

    I would like to know how to maximize the similarity in appearance of graphs as they appear in the graph window and as they appear when exported, in particular to PDF.

    Font sizes, etc., are slightly different between the graph window and a subsequently generated PDF. Usually this is not a problem but occasionally it has been frustrating to find, for example, graph titles escaping the margins of the pdf.

    I have experimented a bit with graph set window, in particular changing the fontfaces to match those of eps (see graph set for these options), and this seems to improve the match, but I'm not sure whether this is the best way to go about this, if it will hold up generally, or if there are possible negative unintended consequences.

    Many thanks,

    BL

    PS - Stata 13.1 SE on W10-64bit
    PPS - If possible, I would like to avoid calling an external program like epstopdf since, when last I checked about a year ago, calling external programs was difficult-to-impossible when running Stata in batch mode on Windows.

  • #2
    What specifically is the difference? And are you referring to differences in electronic or hard copy of the graphs? Are the aspect ratios being held constant when viewed in a PDF viewer? I've not had any issues with rendering, but any code you can provide that produces the error would make it possible for others to replicate the error.

    Comment


    • #3
      Here is a very simple example:

      Code:
      sysuse auto, clear
      scatter weight length, ///
        title("This is a long title that just barely fits in the Stata graph window") ///
        subtitle("But it does not fit when exported to PDF")
      
      graph export example_diff_gph_pdf.pdf

      Comment


      • #4
        The title doesn't fit in the Graph window when I run your code.

        Click image for larger version

Name:	title.png
Views:	1
Size:	16.5 KB
ID:	1313332

        Comment


        • #5
          Have you tried something like:

          Code:
          sysuse auto, clear
          scatter weight length, ///
              title("This is a long title that just barely fits in the Stata graph window", span) ///
              subtitle("But it does not fit when exported to PDF")
          As Friedrich Huebler pointed out, this is an issue with the length of the title more generally (and I was able to replicate the same issue on OSX). The span option for title will center the text, but if you have long titles, why not break them into multiple lines ahead of time?

          Comment


          • #6
            You can also reduce the size of the font in the title.
            Code:
            sysuse auto, clear
            scatter weight length, ///
              title("This is a long title that just barely fits in the Stata graph window") ///
              subtitle("But it does not fit when exported to PDF") name(g1)
            scatter weight length, ///
              title("This is a long title that just barely fits in the Stata graph window", span) ///
              subtitle("But it does not fit when exported to PDF") name(g2)
            scatter weight length, ///
              title("This is a long title that just barely fits in the Stata graph window", size(medlarge)) ///
              subtitle("But it does not fit when exported to PDF") name(g3)

            Comment


            • #7
              Thanks to both of you for your helpful replies. Just to clarify, this issue is not so much whether the title overflows in this particular case, it's that there are differences in the appearance of the graph between the graph window and the PDF. This can be frustrating (a) because I might not realize an adjustment needs to be made until later in the process and (b) to make the required adjustment, there's a tedious process of creating and exporting the graph, checking the pdf, etc.

              So, what my question boils down to is whether there is a set of settings that will reduce the chance of this happening, i.e. produce graphs on-screen and as PDFs that are as similar as possible. I realize there may not be a 100% effective solution, but anything that reduces differences would be helpful.

              Comment


              • #8
                @Bert Llyod this is a somewhat related use case I was trying to address with the program I wrote for generating customized scheme files. There is a version in the SSC, but the most recent version can be installed using:
                Code:
                 net inst brewscheme, from("http://www.paces-consulting.org/stata")
                Someone recently pointed out a bug to me that should be fixed in the version above. I'm wanting to hopefully identify any remaining bugs/issues prior to sending an update to the SSC archives.

                Comment

                Working...
                X