Reputation: 519
I was trying to save the output of a gnuplot plot as pdf using pdfcairo terminal by using the following code below:
reset
set terminal qt 1 noraise enhanced
set xlabel "Time (sec)"
set ylabel "Displacement (m), Velocity (m/s)"
set title "Vanderpol Oscillator using Runge Kutta's method"
set key box top left spacing 1.5
plot 'data.txt' using 1:2 with lines title 'Displacement', \
'data.txt' using 1:3 with lines dashtype 2 linecolor 7 \
title 'Velocity'
set terminal pdfcairo enhanced color notransparent
set output 'vanderpol_pdfcairo.pdf'
replot
unset output
unset terminal
However the output of qt
terminal and output of pdfcairo
terminals are slightly different. The output via pdfcairo
is given below:
The qt
terminal output, however, looks like this:
Note the legend box for the difference. Is there a way to save the qt
terminal output via gnuplot commands?
Partial data file is given below for the sake of completeness.
# x y1 y2
0.00000000 2.00000000 0.00000000
0.100000001 1.99093056 -0.172638252
0.200000003 1.96694851 -0.300697386
0.300000012 1.93182826 -0.397370458
0.400000006 1.88817477 -0.472826719
0.500000000 1.83771741 -0.534503400
0.600000024 1.78155255 -0.587733626
0.699999988 1.72032225 -0.636360347
0.800000012 1.65433800 -0.683229983
0.900000036 1.58366048 -0.730560362
1.00000000 1.50814855 -0.780208290
1.10000002 1.42748523 -0.833866239
1.20000005 1.34118605 -0.893212378
1.30000007 1.24859416 -0.960030317
1.39999998 1.14886522 -1.03630733
1.50000000 1.04094255 -1.12430966
1.60000002 0.923527122 -1.22661817
1.70000005 0.795047462 -1.34608305
1.80000007 0.653641462 -1.48561156
1.89999998 0.497173846 -1.64762938
2.00000000 0.323334455 -1.83295059
2.10000014 0.129894391 -2.03868413
2.20000005 -8.47651213E-02 -2.25484443
2.29999995 -0.320725024 -2.45990729
2.40000010 -0.575173676 -2.61727047
2.50000000 -0.840935469 -2.67749405
2.60000014 -1.10578239 -2.59248185
2.70000005 -1.35379517 -2.34094477
2.79999995 -1.56921184 -1.94889915
2.90000010 -1.74111176 -1.48351884
3.00000000 -1.86605072 -1.02113712
3.10000014 -1.94729543 -0.615993023
3.20000005 -1.99192703 -0.290263236
3.29999995 -2.00793982 -4.20439988E-02
3.40000010 -2.00246644 0.142086729
3.50000000 -1.98111856 0.278029412
3.60000014 -1.94798887 0.379831105
3.70000005 -1.90591788 0.458439767
3.79999995 -1.85680115 0.521885574
3.90000010 -1.80185127 0.575913012
4.00000000 -1.74179327 0.624632478
[EDIT]: How is qt
terminal saving the displayed output to pdf? What is the c/c++ code for the same?
Upvotes: 3
Views: 6002
Reputation: 15118
Two different graphics libraries are involved. No surprise: the qt terminal uses Qt and the pdfcairo terminal uses cairo. If you want a better match of interactive display to hard-copy output you have several options.
The qt terminal window has a widget at the top left to create a pdf copy of the current plot using the Qt library. That should match the screen display very closely.
The wxt interactive terminal is an alternative to the qt terminal. It uses the cairo graphics libraries, so the wxt screen display should be close that the output produced by the pdfcairo terminal.
The wxt terminal window has a widget for hardcopy output, just as the qt display window does. That output should be even closer to the screen display.
There is not currently a command line option to produce a pdf file using the Qt libraries.
Upvotes: 2