Gnuplot: Tilde Symbol in pngcairo image - gnuplot

I use Gnuplot with pngcairo terminal and my question ison can I put the tilde symbol on a letter?
I know that in latex the command is \tilde{f}.
I've tried with f{\Symbol 304} or f\\~.
How can I do?

Check help enhanced text.
With this:
### tilde over character
set label 1 "~f{0.9\\~}" at screen 0.25, 0.75 font ",20"
plot x
You get the following (wxt terminal):

Related

GNUplot plot function doesn't save file

Ive installed GNUplot on OSX using
brew install gnuplot
in terminal. I can open gnuplot using
gnuplot
in terminal. I then use
set terminal png
But then if I try to plot anything I just get random characters printed to the screen.
e.g
plot sin(x)/x
returns
Q%#??L?r??T? 89??? ?v?*?`"?Ө~???;???o.?/???jk??W}???f??C8???rR??2j?? GE?e.?fJ??zv!S?f]|???=?^<}?Bq?m??
^<??C&G{nR?Ũ?"~?(YA#?????ϱ??????yd?В->桮???o??~??*-R??m???Q??????Я??=?
ң?9????(Z<?C]???߫???\?wH??Ѧ??(Z?C_???ww???w??ǣ??txE??y???F??q%?n??Q???ǁ|????(Z???X#???V??q3????Pӣ??y?y?e?p???EHK?y????xj?l7?{ݟ?g?1BG?Q?8???g/oD??k#g??h?1}=?n????:????<?????
??Ń'?IEND?B`?gnuplot>
The same thing happens if I set the terminal to jpeg.
gnuplot just prints the contents of a png file that you want to create. You should specify the file name:
set output "myfile.png"

gnuplot linux to windows

I am running the below Gnuplot code in Linux.
I want to know how I can run the same code on windows?
Thanks a lot!
reset
set termoption dash
set terminal postscript portrait enhanced color "Helvetica" 10
set output '| ps2pdf - Plot.pdf'
set datafile separator ","
mag = 5
set grid
set border 31 lw 1
set key off
set style line 1 lt 1 lw 10 pt 6 ps 0.4 lc rgb '#D3D3D3'
TET_0011 = "/home/soheil/university/quadratic/KAPPA & MU/TET-VOIGT-SR-0.01.txt"
plot TET_0011 u 1:4 w l ls 1 title "VOIGT"
Gnuplot is supported on windows using Cygwin or MinGW.
Checkout the binary download page for gnuplot windows binaries.
The gnuplot code you post above will remain the same.
The only problem i see on windows is the lack os ps2pdf
Fortunately, you could set to generate PDF directly, instead of set terminal postscript ... you should have pdfcairo terminal
set terminal pdfcairo OPTIONS
It is available on gnuplot on windows, v5.0.x

Use gnuplot command without prompt

To use the Gnuplot (On linux Ubuntu 16.04) command directly by specifying arguments without using the its prompt, I enter this for example :
gnuplot -e "filename='DataFile.txt'" SettingsFile
Where SettingsFile looks like this :
plot filename with lines
set title "Total Packets consumption"
set xlabel "Time"
set ylabel "Packets"
set datafile separator ","
pause -1
And the DataFile.txt looks like this :
Packets, Time(in seconds) :
13392,120
24607,240
23867,360
21764,480
20727,600
20004,720
19719,840
19758,960
19728,1080
20168,1200
19737,1320
19729,1440
20135,1560
20006,1680
21301,1800
19923,1920
20002,2040
19761,2160
20918,2280
22756,2400
22820,2520
23370,2640
22987,2760
22956,2880
24427,3000
23527,3120
24009,3240
23832,3360
23464,3480
23652,3600
11212,3654
First question :
Is there a way to set into that SettingsFile a png OutputFile ? So I can enter it as an argument to the Gnuplot command just as I did with the DataFile. (I want to use it this way, because I want to invoke it from an external code)
I want to achieve something like this :
gnuplot -e "filename='DataFile.txt'" SettingsFile OutputFile.png
Second question :
The screen output that I get from Gnuplot shows the xtics differently than expected :
Notice also that the axis titles are not shown !
Now if I try to resize the window I get this :
The graph gets bizarrely flipped, with the titles set and the tics being updated as desired.
How should I fix these two problems, first mentioning an output file in the SettingsFile, and second the xtics not being showed properly and third this strange behavior in the screen output ?
Several commands can be added to gnuplot -e through semicolons, for example:
gnuplot -p -e 'filename="data.txt"; fileout="image.png"' SettingsFile
Your SettingsFile should already have a line configuring the terminal type:
set terminal png
set output fileout
set title "Total Packets consumption"
set xlabel "Time"
set ylabel "Packets"
set datafile separator ","
plot filename using 2:1 with lines
If you want more control over your code, try with this script (gnuplot 5.0+):
filename=(ARGC>0 ? ARG1 : 'DataFile.txt' ) # By default filename=DataFile.txt
# If called with one argument (ARGC=1)
# then `filename=ARG1`
if(ARGC>1){
# if called with two arguments (ARGC=2), then configure a png output
set terminal png
set output ARG2
}
set title "Total Packets consumption"
set xlabel "Time"
set ylabel "Packets"
set datafile separator ","
# the plot command ALWAYS at the end of the script after the settings
plot filename using 2:1 with lines
If you want to plot 'DataFile.txt' (by default) interactively:
gnuplot -p SettingsFile
If you want to plot another file, e.g. AnotherData.txt:
gnuplot -p -c SettingsFile AnotherData.txt
If you want to plot another file and save it as PNG:
gnuplot -p -c SettingsFile AnotherData.txt Output.png
The -p argument lets plot windows survive after main gnuplot program exits. Thw -c argument load script using gnuplot's "call" mechanism and pass it the remainder of the command line as arguments. See How to pass command line argument to gnuplot?
Notice that your script plots the datafile first, and THEN configure the labels, title and datafile separator. That is why you see weird tics.

plot is not generated (gnuplot from command line)

In sample.dat I have:
set terminal pngcairo transparent enhanced font "arial,10" fontscale 1.0 size 500, 350
set output 'simple.2.png'
plot [-pi/2:pi] cos(x),-(sin(x) > sin(x+1) ? sin(x) : sin(x+1))
From ubuntu/terminal I execute:
gnuplot -e "filename='sample.dat'"
but the simple.2.png file is not created. How do I export a plot to e.g png using gnuplot from command line?
I have no idea where you got that from!
To execute a gnuplot script (here called simple.gp), simply call
gnuplot simple.gp
You should keep the extension .dat for data files.

Font in Gnuplot Postscript Terminal

I would like gnuplot to use the same font in the postscript-terminal as it does in the wxt-terminal. The Gnuplot help says that wxt uses "Sans" by default. Now, if i set the terminal to
gnuplot> set term post enhanced color "Sans" 12
Terminal type set to 'postscript'
Options are 'landscape enhanced defaultplex \
leveldefault color colortext \
dashed dashlength 1.0 linewidth 1.0 butt noclip \
palfuncparam 2000,0.003 \
"Sans" 12 '
then the font looks very different to the one in wxt.
I am using Ubuntu 10.04 lucid.
Which font would you suggest me to use? Any ideas welcome.
I've also tried "cm-super" to get latex-fonts (computer modern) in gnuplot. Actually it worked, but the text overlapped boxes and margins very often!
Greets,
mefiX
Since the considered plots are part of a LaTeX document, I decided to use the computer modern fonts described earlier.
gnuplot> set term post enhanced color fontfile "/usr/share/texmf/fonts/type1/public/cm-super/sfss1200.pfb" "SFSS1200"
Terminal type set to 'postscript'
Font file '/usr/share/texmf/fonts/type1/public/cm-super/sfss1200.pfb' contains the font 'SFSS1200'. Location:
/usr/share/texmf/fonts/type1/public/cm-super/sfss1200.pfb
Options are 'landscape enhanced defaultplex \
leveldefault color colortext \
dashed dashlength 1.0 linewidth 1.0 butt noclip \
palfuncparam 2000,0.003 \
"SFSS1200" 14 fontfile "/usr/share/texmf/fonts/type1/public/cm-super/sfss1200.pfb" '
As already mentioned, you can install these under ubuntu by calling
# apt-get install cm-super
on the root command line.
Note that the characters in SFSS1200 describe font encoding (Latin1, ...), style (Sans-Serif, ...) and desired resolution in dpi.

Resources