Return to Ferret FAQ

Changing line thickness in PostScript files


My lines or labels show up with too thin a line when I convert to PostScript plot. How can I make them thicker?


This plot has three different line thicknesses in Ferret But when translated to PostScript all the lines look thin
[Ferret plot] [Thin lines on PostScript plot]

Run Ferret to generate a plot, then from the Unix command line translate it to a PostScript plot:

       % ferret
    yes? SET MODE META
    yes? PLOT/LINE=1/I=1:15/TITLE="Three curves" 1./i
    yes? PLOT/LINE=7/I=1:15/OVER 1./(i-2)
    yes? PLOT/LINE=13/I=1:15/OVER 1./(i-3)
    yes? quit
      % Fprint -R -o metafile.plt has the thin lines above.


On very high resolution printers (1200 dpi), and some display tools it is difficult for the eye to differentiate single, double, and triple pixel thick lines. They all appear "thin". To solve the problem we need only thicken the lines by more than the normal amount. This can accomplished through modifying the PostScript file ( before sending it to the printer or through modifications to the Ferret metafile (filename.plt) before converting it to PostScript with Fprint or gksm2ps.

Some Solutions:

  1. It is possible to directly modify the line thickness in the PostScript file generated by Fprint or gksm2ps. If you read through the first lines of the PostScript file you can find the lw definition, linewidth. In your favorite editor, changing
             3000 div setlinewidth      to      1000 div setlinewidth
    will make ALL the lines in the plot three times thicker, including the text and axes. This will differentiate the three lines, making the plot look like the one on the left above.

  2. Here is a unix shell script, ps_thicken, which will thicken all line widths. To triple all the line widths in a postscript file that was written by Fprint (i.e. gksm2ps)

    ps_thicken 3 >

    #!/bin/csh -f
    # Usage: ps_thicken ps_file factor
    # Thickens lines in a PostScript file by changing the linewidth macro,
    # Result goes to standard output.
    # get list of all arguments
    set args = ($*)
    # if not enough arguments, complain.
    if ($#args < 2) then
       echo "Usage: ps_thicken ps_file factor"
       echo "Thickens all lines in a PostScript file by changing the linewidth macro."
       echo "Result goes to standard output."
       exit 1
    sed -e "s/^\/lw {\(.*\) div setlinewidth/\/lw {$2 mul \1 div setlinewidth/" $1

  3. To change only some of the line characteristics, work with the metafile. We have a Unix script called change_widths which you can save, and from the shell, make change_widths executable and apply it to a metafile.
                % chmod +x change_widths
                % change_widths metafile.plt
    Applying the change_widths script to a metafile will have the effect of doubling the thickness of lines generated with PLOT+ pen numbers 7 and 13 (or equivalently /COLOR=BLACK/THICK=2 and /COLOR=BLACK/THICK=3, respectively).

    change_widths will result in the new file metafile_thick.plt.

                % change_widths metafile.plt
                % Fprint -R -o metafile_thick.plt
    Upon converting the metafile to PostScript via Fprint as usual, the result also looks like the plot on the left above.

  4. A similar approach can be used to change the thickness of any of the lines. Look inside the metafile.plt file to see where line thicknesses are set. Find the section near the start of the metafile which lists characteristics of the different numbered lines. A portion of a metafile is listed below. The third column is the line number (1, 7, 13, ...) and the 5th column is line thickness.
            . . .
                    51    29     1     1    1.00000     1
                    51    29     7     1    2.00000     1      <-- we'll change this line
                    51    29    13     1    3.00000     1
                    51    29     2     1    1.00000     2
                    51    29     8     1    2.00000     2
    To double the thickness only of /LINE=7 (the double thick black plotting line), while leaving all other lines unaffected, change
     51    29     7     1    2.00000     1   to   51    29     7     1    4.00000     1
    The double thickness, "2.00000" is changed to quadruple thickness "4.00000" in the GKS metafile -- then the PostScript is generated as usual.

    A similar approach can be used to change the thickness of any of the lines. The mapping through which line color and thickness determine the pen number in the metafile can be found in the Ferret Users Guide (Chapter6, sec 1.5.2) . Pens 0-6 are thin (nominal thickness "1.00000"), 7-13 are double (nominal thickness "2.00000"), and 14-20 are triple (nominal thickness "3.00000"). Suppose you want to change /thick=2/color=red (pen 8) from double to triple thick and /thick=3/color=black (pen 14) from triple to 5x. Edit the file or use a Unix shell command, "sed" substitution, to accomplish this. (The command is one long command line.)

    sed -e "s/51    29     8     1    2.00000/51    29     8     1    3.00000/" -e "s/51
    29    14     1    3.00000/51    29     14     1    5.00000/"
    Typically one wants to redirect the output to a new file, so the full command becomes
    sed -e "as above" metafile.plt > new_metafile.plt

Last modified: Oct 23, 2000