Search code examples
overlaypostscript

Overlaying or merging multiple .ps files


I have used gmt to create several .ps files of x - y graphs with identical axes. I have several sets of data, each containing between 14 and 20 plots. Each plot is in a separate directory.

I would like to overlay every .ps within a dataset, in order to show correlation between the plots.

I know this is similar to the thread posted here:

overlay one pdf or ps file on top of another

but I don't have to deal with multiple pages.

I'm not a programmer, I'm a student! I would really appreciate a quick-ish way to stack them on top of each other to see an overall trend.

If not, I'm off to buy a stack of OHP films and find the nearest photocopier.... which would not look nearly as shiny.

All help is appreciated!


Solution

  • I've done something like this before, using GMT to produce two plots (of opposite sides of the Earth) to PS and overlaying them, one flipped 180 degrees and reflected (that is, depicting the Earth as a projective plane with each point equated with its antipode).

    This was my code:

    #!/bin/sh
    
    GMT gmtset BASEMAP_FRAME_RGB +192/192/192
    GMT gmtset BASEMAP_FRAME_RGB 0/0/0
    GMT pscoast -JS-60/0/16 -R0/360/-90/90 -Di -A5000 -N1 -W -GP300/15:FLightRedB- -SWhite -P -K > mapa.ps
    GMT pscoast -JS120/0/16 -R0/360/-90/90 -Bg30/g15 -Di -A5000 -N1 -W -GP300/15:FLightGreenB- -Sp1/50:F-B- -P -O > mapb.ps
    sed -i 's/595 842/600 600/g' mapa.ps
    sed -i 's/PSL/180 rotate -1 1 scale 0 -1890 translate \nPSL/' mapb.ps
    cat mapa.ps mapb.ps > mapc.ps
    ps2pdf mapc.ps
    

    Commenting out the second sed line overlays them without flipping the second one. You can probably achieve what you want by tweaking this script and replacing the GMT commands with whatever you're using. The -O option used for the second plot sets overlay mode, which omits the PS code that triggers the creation of a new page. Then you can just cat them together.