Search code examples
plotexportpdf-generationgnuploteps

Missing label when converting eps to pdf


I use the following gnuplot script in order to plot a data file

reset
unset key
set size 1,1

set xrange [-10.1:11]
set yrange [-45:45]

set xlabel 'x'
set lmargin 6
set label 1 "~x{0.7.}" font "Helvetica, 20" at graph -0.1, graph 0.5

set xtics 2
set ytics 15

set mxtics 5
set mytics 5

plot "pss_data.dat" u 1:2 w dots lc rgb 'black'

set term postscript eps enhanced "Helvetica" 20 size 7in, 5in
set output 'plot.eps'
replot

reset
set terminal windows

quit

The exported .eps file is the following.

enter image description here

Well, in fact this is the corresponding .pdf file using Adobe Acrobat XI in order to make the conversion. However, the .pdf output contains not only the plot but all the unwanted black area above it! In an attempt to get rid off the white area I used the command line

epstopdf plot.eps

The output is the following

enter image description here

Now, the white area has been removed but the label at the y axis is also missing!

Any ideas? I want to have in a .pdf file only the plot (without the above white area) but with the label at the y axis.

Many thanks in advance.


Solution

  • I would avoid the conversion all together by using one of gnuplot's pdf terminals (I like pdfcairo) and just use ylabel instead of set label 1 ... at graph.... Here's a simple script that you can modify for your purposes:

    set term pdfcairo enhanced font "Helvetica,20"
    set output "test.pdf"
    set ylabel "~x{0.7.}" rotate by 0  #default rotation is 90
    set xlabel "x"
    plot sin(x)
    

    Ultimately, what is happening with your script is that gnuplot is putting the label off of the viewable canvas. Some reason adobe still puts the label on the (converted) output, but I would assert that they are wrong in this case -- (they're essentially ignoring your bounding box). Of course, you could move/adjust the bounding box as suggested in the answer by andyras -- but I would argue that is a pretty hacky solution.