Announcement

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

  • Graph export .eps format too big

    Dear Statalisters,

    I've plotted a graph using the following command:

    Code:
    bys year: egen line1= pctile(data), p(50)
    bys year: egen line2= pctile(data), p(75)
    bys year: egen line3= pctile(data), p(90)
    twoway (line line1 year) (line line2 year) (line line3 year)
    graph export test.eps, replace
    To my surprise, this .eps file is more than 300Mb, and I'm having difficulties calling it from latex. All other graphs that I've plotted is much smaller (10Kb). Although my dataset is huge (8Gb), I don't understand why this particular .eps file will be huge as well. There are reasonable number of points on the x-axis (17 years).

    What can I do to reduce the size of my graph, given that I do not want to change the .eps format? Or must I export the graph as pdf or any other format?

  • #2
    I realized that I should have added the following line before plotting the graph:

    Code:
    collapse line*, by(year)
    I've tried exporting the graph using pdf, and it still resulted in a pdf file of 1Mb. However, after collapsing the data, the file size was reduced to 14Kb. I'm assuming that Stata plotted all the points (which are essentially the same), and saving the file did not aggregate the results.

    Comment


    • #3
      A different solution that won't destroy your dataset (no -collapse-) is the following:

      Code:
       
      bys year: egen line1= pctile(data), p(50) 
      bys year: egen line2= pctile(data), p(75) 
      bys year: egen line3= pctile(data), p(90)  
      
      egen tag = tag(year)  
      twoway (line line1 line2 line3 year if tag==1)   
      graph export test.eps, replace 
      
      drop tag

      Comment

      Working...
      X