3

I am generating mapped 3D plots using the following config file (XRANGE and YRANGE are set later)

#!/usr/bin/gnuplot    
reset
set term postscript eps enhanced

set size square
set xlabel "X position"
set ylabel "Y position"

#Have a gradient of colors from blue (low) to red (high)
set pm3d map
set palette rgbformulae 22,13,-31

set xrange [0 : XRANGE]
set yrange [0 : YRANGE]

set style line 1 lw 1

unset key

set dgrid3d 45,45

set hidden3d

splot "data.data" u 1:2:3

The resulting image looks something like this

GnuPlot Image

Note: I have converted to jpg so the quality is lower, and I have placed a border around the image.

A great deal of space is wasted above and below. This is not a problem until I embed the image into a LaTex document, at which point it will look like so (again, pdf document converted to jpg image)

enter image description here

The image on the right is also created with GnuPlot, but it is slightly larger (as is evident by looking at the border I have drawn around the top two images). The reason for this is because GnuPlot pads the 3D plot with top and bottom white space. How can I remove this without having to manually edit all 50+ plots I have?

3 Answers 3

4

There are two solutions to this, one is unreliable, the other is a hack.

  1. Using GnuPlot, the margin settings can be used to specify distances from the appropriate margins. For example, setting lmargin 0 and bmargin 0 essentially pushes the axes off the page. Similar values can be assigned to the tmargin and rmargin to stretch the graph. Although this worked for 2D graphs, it did not work for 3D graphs (I suspect this has to do with the fact that I set the graph to be a square).

  2. When graphs are set to be of square size, Gnuplot still calculates for the entire screen. The eps file can be manipulated directly to change this by looking for a line like so %%BoundingBox: 50 50 410 302 and changing 410 to something smaller. Alternatively, and this is what I did, you can run eps2eps in.eps out.eps and it will crop it for you. Just make sure in.eps is not the same file as out.eps or it won't work.

2

I also crop the Bounding Box afterwards, since I hate playing around with margins in gnuplot. I realized that somehow, eps2eps indeed does adjust the bounding box, but it also transforms text (labels etc) into pixel-graphic?!

I usually use "epstool" which conserves text as text when croping the bb, the command I use is:

epstool --copy --bbox in.eps out.eps

3
  • Gnuplot has some of the worst documentation around. The sad thing is that there are very few alternatives. Although eps2eps gets rid of the margin, it doesn't solve the underlying problem: for some reason gnuplot plots 3D graphs slightly smaller than 2D graphs. Even if you tweaked the font so when stretched to the same size in LaTex, you then have to deal with the fact that Latex subfigures can not be spaced apart, so you now have two graphs smushed together.
    – puk
    Jan 9, 2012 at 11:33
  • @puk Well, feel free to suggest improvements to the documentation.
    – Christoph
    Sep 24, 2014 at 7:28
  • This works very well instead of this originally I convert eps to pdf then use pdfcrop command but this is better.
    – sikisis
    Dec 7, 2015 at 9:24
1

Use the <scale> argument in set view, this will magnify the plot without changing text size or title position.

In your case, because you use the map view, you need:

set view 180,0,1.5

where 180,0 is equivalent to map view and 1.5 is the scaling factor.

1
  • 1
    As a note: The upcoming 5.0 version has a scale, so that you can use set pm3d map; set view scale 1.2.
    – Christoph
    Sep 24, 2014 at 7:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.