# PostScript Resolution Affects Output

QUESTION: How does PostScript resolution affect my output?

ANSWER: PostScript devices have a higher resolution than your display device. If you don't know this, you will wonder why certain "features" like line thickness are different on your display and in your PostScript output.

The fact that PostScript devices have a higher resolution is probably self-evident (after all, it is probably one reason you are using PostScript output), but it is surprising to me how many people forget it when they try to compare what they see on the display with their PostScript output. It is probably the major reason you can't get a totally WYSIWYG plot in PostScript. And it is certainly the reason people who insist on positioning graphics and text with device coordinates are soon reduced to despair.

Most display devices have resolutions of about 75 pixels per centimeter. Your PostScript device has a resolution of 1000 pixels per centimeter. (You can find out how many pixels per centimeter there are for the current graphics device by looking at the system variables !D.X_PX_CM and !D.Y_PX_CM.) This affects your output in both large and small ways.

For example, suppose you have a 500 by 500 pixel display window and you want to draw a box centered in that window that encloses 80 percent of the window. You could draw the large box like this:

```   xpts = [50, 50, 450, 450, 50]
ypts = [50, 450, 450, 50, 50]
cgPlotS, xpts, ypts, /DEVICE
```

But if you executed the same code with the PostScript device as your current device, the box would be a very tiny box down in the lower-left of the page. The reason, of course, is that 400 pixels on our display is about 5.3 centimeters, but 400 pixels in PostScript is less than half a centimeter.

In fact, the only way to guarantee that the box encloses 80 percent of the output window is to draw it using normalized coordinates, like this:

```   xpts = [0.1, 0.1, 0.9, 0.9, 0.1]
ypts = [0.1, 0.9, 0.9, 0.1, 0.1]
cgPlotS, xpts, ypts, /NORMAL
```

This code works both on your display and in a PostScript window. In fact, a good rule of thumb is to never write IDL code that positions graphics with device coordinates if you can help it. Always use normalized coordinates (my favorite) or data coordinates.

Other effects of increased resolution are more subtle. For example, consider the widths of lines. A line that is one pixel wide on your display covers proportionally more of the plot area than a line one pixel wide in PostScript. In fact, I don't think lines are drawn one pixel wide in PostScript since the line would be so thin it would be almost impossible to see. I don't know what the official scale factor is, but I use a rule of thumb factor of 2.5 for line thicknesses and get reasonable results. For example, if I am changing the thickness of my lines in plots, by code will look like this:

```  factor = (!D.NAME EQ 'PS') ? 2.5 : 1.0
cgPlot, data, THICK=2.0 * factor
```

If you set up your PostScript device with cgPS_Open, as I do, and close the device with cgPS_Close, then these details are handled automatically for you.

 Web Coyote's Guide to IDL Programming