Saturday, April 07, 2018

Generating graph / figure in publication quality

As I was recently preparing a poster for ATS Internal Conference, I was told that the plots I provided were not in high quality. When placing the plots on the poster, they became blurry. I realized that the issue was with the DPI. 

DPI is used to describe the resolution number of dots per inch in a digital print and the printing resolution of a hard copy print dot gain. High DPI = High Resolution.

The journal may have a requirement for the minimum resolution for the graphs and figures, for example, the PLOT One requires the resolution in the range of DPI 300-600. The Science magazine has the following requirement: 
Resolution. For manuscripts in the revision stage, adequate figure resolution is essential to a high-quality print and online rendering of your paper. Raster line art should have a minimum resolution of 600 dots per inch (dpi) and, preferably, should have a resolution of 1200 dpi. Grayscale and color artwork should have a minimum resolution of 400 dpi, and a higher resolution if possible.
Wiley had a paper discussing the challenges the authors might face for providing the high resolution figures. See the editorial: How to meet dots per inch requirements for images

I used SAS procedure sgplot to create the plots. The default DPI is 100, which is too low for publication or poster. Fortunately, there are easy ways to change the DPI for the output plots. Below are some programs for doing so: 

*default DPI=600; low resolution;
ods listing gpath='c:Temp\';
ods graphics on;
proc sgplot data=sashelp.stocks (where=(date >= "01jan2000"d
                                 and date <= "01jan2001"d
                                 and stock = "IBM"));
   title "Stock Volume vs. Close";
   vbar date / response=volume;
   vline date / response=close y2axis;
run;
ods graphics off;
ods listing close;


*set DPI=400;
ods listing gpath="c:\Temp\" dpi=400;
ods graphics on;
proc sgplot data=sashelp.stocks (where=(date >= "01jan2000"d
                                 and date <= "01jan2001"d
                                 and stock = "IBM"));
   title "Stock Volume vs. Close";
   vbar date / response=volume;
   vline date / response=close y2axis;
run;
ods graphics off;
ods listing close; 

*set DPI =400 and also use style=journal;
ods listing gpath="c:\Temp\" style=journal dpi=400;
ods graphics on;
proc sgplot data=sashelp.stocks (where=(date >= "01jan2000"d
                                 and date <= "01jan2001"d
                                 and stock = "IBM"));
   title "Stock Volume vs. Close";
   vbar date / response=volume;
   vline date / response=close y2axis;
run;
ods graphics off;

ods listing close;

When high DPI is chosen, the size of the file will increase. For the same plot, the file sizes for three plots (in png format) above are 26, 160, and 158 kb. 

The following program will service the same purpose, but use ods pdf commend. 

ods pdf file="c:\Temp\test.pdf";
proc sgplot data=sashelp.stocks (where=(date >= "01jan2000"d
                                 and date <= "01jan2001"d
                                 and stock = "IBM"));
   title "Stock Volume vs. Close";
   vbar date / response=volume;
   vline date / response=close y2axis;
run;
ods pdf close;


ods pdf file="c:\temp\test.pdf" dpi=600;
proc sgplot data=sashelp.stocks (where=(date >= "01jan2000"d
                                 and date <= "01jan2001"d
                                 and stock = "IBM"));
   title "Stock Volume vs. Close";
   vbar date / response=volume;
   vline date / response=close y2axis;
run;
ods pdf close;


ods pdf file="c:\Temp\test.pdf" style=journal dpi=600;
proc sgplot data=sashelp.stocks (where=(date >= "01jan2000"d
                                 and date <= "01jan2001"d
                                 and stock = "IBM"));
   title "Stock Volume vs. Close";
   vbar date / response=volume;
   vline date / response=close y2axis;
run;
ods pdf close;

The same issue with graph quality is also true when we use R. There is a RES = option to select the desired DPI. Please see the blog post by Daniel Hocking "High Resolution Figures in R".

1 comment:

Mohsin Mumtaz said...

Hey Guys, Use this online converter for file converting;

Files Converter Online