Announcement

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

  • Saving high quality graphs for publication

    Dear all, I am struggling with this issue and I hope some of you can help me.

    I need to produce some graphs in .tif or .jpg at the resolution of 300 dpi. After producing the graph with the Stata graph editor, I only found the option to save .tif. Unfortunately, the file produced is only 96 dpi, and I have no clue on how augment the resolution as requested by the editor.

    May any of you suggest something in this sense?

    Thanks a lot, best, Giorgio

  • #2
    Note I've never used this and I don't know why an editor WOULD ask you to do this, but does this work?

    Comment


    • #3
      This method may help you. First you need to export the image to svg format using stata, then use inkscape software (https://inkscape.org/) to export the svg image to jpg (or tif) format and set the desired dpi when exporting.

      Comment


      • #4
        I thought you can use the fact that image width or height in inches x DPI value = pixel width or height. But that does not seem to work. But there is a command line tool called ImageMagick that can fix that. You can download it from https://imagemagick.org/script/download.php.

        Here is an example:

        Code:
        . sysuse auto, clear
        (1978 automobile data)
        
        . twoway scatter price mpg || lfit price mpg, xsize(7.36) ysize(5.35333)
        
        . graph export "price_by_mpg.tif", replace width(2208) height(1606)
        file /Users/dvm/Downloads/price_by_mpg.tif saved as TIFF format
        
        . !identify -format "%[fx:w/300] by %[fx:h/300] inches" "price_by_mpg.tif"
        
        7.36 by 5.35333 inches
        . !identify -format "%w by %h pixels" "price_by_mpg.tif"
        
        2208 by 1606 pixels
        . !identify -format %x "price_by_mpg.tif"
        
        72
        . // Change DPI to 300 from 72
        . !convert -density 300 "price_by_mpg.tif" "price_by_mpg.tif"
        
        
        . // Confirm Everything Worked
        . !identify -format "%[fx:w/300] by %[fx:h/300] inches" "price_by_mpg.tif"
        
        7.36 by 5.35333 inches
        . !identify -format "%w by %h pixels" "price_by_mpg.tif"
        
        2208 by 1606 pixels
        . !identify -format %x "price_by_mpg.tif"
        
        300
        Last edited by Dimitriy V. Masterov; 24 Jan 2023, 00:39.

        Comment

        Working...
        X