I am trying to incorporate greek symbols into my graph using following code, but keep getting similar error twice.
warning: enhanced text mode parser - ignoring spurious }
warning: enhanced text mode parser - ignoring spurious }
reset
# svg
#set terminal svg size 410,250 fname "Times New Roman" \
set terminal svg size 410,250, enhanced fname 'Times New Roman' \
fsize "12" rounded dashed
set output "data1.svg"
set tics nomirror
# color definitions
set style line 1 lc rgb "#8b1a0e" pt 1 ps 1 lt 1 lw 2 # --- red
set style line 2 lc rgb "#5e9c36" pt 2 ps 1 lt 2 lw 2 # --- green
set key bottom right
plot "abc.htm" using 1:2 title "N('\alpha', T)" w lp ls 1, \
"abc.htm" using 1:3 title "N(\beta, T)" w lp ls 5
PS: The code was running fine until I enabled enhanced mode of svg terminal, as I needed it for inserting greek letters in my graph legends. I am using version 4.6, patch level 5. Can any one help me out?
The correct way is to
use enhanced option of the terminal (you did)
wite {/Symbol a} for an alpha.
Search for symbols + gnuplot on the web, you'll find lists like http://mathewpeet.org/lists/symbols/ with codes understood by gnuplot!
Use a proper encoding (UTF-8) and insert the characters directly:
reset
set encoding utf8
set terminal svg size 410,250 enhanced fname 'Times New Roman' fsize "12" rounded dashed standalone
set output "data1.svg"
set linetype 1 lc rgb "#8b1a0e" lw 2
set linetype 2 lc rgb "#5e9c36" lw 2
set key bottom right
set style function linespoints
set samples 11
plot x title "N(α, T)", 2*x title "N(β, T)"
choose font 'Symbol'
choose corresponding English alphabet for Greek letter, eg. i have chosen 'c' for 'chi', below is the link for other characters.
http://folk.uio.no/hpl/scripting/doc/gnuplot/Kawano/label-e.html
fontsize can be changed easily.
eg...
set ylabel "c" font "Symbol,14"
will produce greek letter 'Chi'.
I have found the way to solve this problem. The Greek letters can be inserted in SVG file using following path in the Inkscape:
Go to Text drop down menu and then click on Glyphs. Next, select font family such as Times New Roman. After that select Greek from script and all from Range options, respectively. Then Greek letters could easily be inserted in the Graph.
Related
I need to make a 2d plot and a 3d plot, which I want to save as .tex files, respectively labo2-mag/latex/position-x-y-over-time.tex and labo2-mag/latex/position-3d.tex. Is there anything wrong with my script ?
# General settings
set tics font ", 14"
set tmargin at screen 0.7
set key at screen 0.3, 0.8 font ",14" spacing 1.3 samplen 0.8 box opaque
# set key outside font ",14" spacing 1.3 box opaque
# Send the border to the background
set border lw 0.1 back
set xlabel '$t$ [s?]' offset 1.7;
set ylabel '$Position$ [m?]' offset -1;
# Plot once 'in the air'
# set terminal unknown
plot "labo2-mag/data/output.out" using 1:2 with points pointtype 6 lc rgb "red" title '$x(t)$', \
"" using 1:3 with points pointtype 8 lc rgb "green" title '$y(t)$', \
"" using 1:4 with points pointtype 6 lc rgb "blue" title '$z(t)$'
# pause 70
# reread
set terminal cairolatex pdf size 10cm, 10cm
set out 'labo2-mag/latex/position-x-y-over-time.tex'
MAX_Y=GPVAL_Y_MAX
MIN_Y=GPVAL_Y_MIN
MAX_X=GPVAL_X_MAX
MIN_X=GPVAL_X_MIN
set xrange [MIN_X-(MAX_X-MIN_X)*0.1:MAX_X+(MAX_X-MIN_X)*0.01]
set yrange [MIN_Y-(MAX_Y-MIN_Y)*0.05:MAX_Y+(MAX_Y-MIN_Y)*0.05]
replot
# reset terminal
splot "labo2-mag/data/output.out" using 2:3:4 with points pointtype 6 lc rgb "red" title '$pos(t)$'
set terminal cairolatex pdf size 10cm, 10cm
set out 'labo2-mag/latex/position-3d.tex'
replot
Your splot command is issued while the first terminal is still active and writing to the first output file. You need to change the terminal and output before doing a new plot. The minimum would be to issue unset output after each of your replot statements.
You might want or need to also set a new intermediate terminal type together with the unset output. I don't understand the "in the air" comment in the script. Do you mean you don't actually want to plot it? You want to view it interactively before plotting to a file? Otherwise maybe set terminal dumb? If it is relevant, please clarify.
I have developped a CGI in bash/html that allow me to generate a graph of my clusters.
Here is an exemple :
This is a graph that works well. The problem is that for some graphs, the percentages overlap or shift far too far from where it should be. Here is my GNUPLOT code:
f(w) = (strlen(w) > 10 ? word(w, 1) . "\n" . word(w, 2) : w)
set title "TITLE"
set terminal png truecolor size 960, 720 background rgb "#eff1f0"
set output "/var/www/html/CLUSTER_NAME.png"
set bmargin at screen 0.1
set key top center
set grid
set style data histograms
set style fill solid 1.00 border -1
set boxwidth 0.7 relative
set yrange [*:*]
set format y "%g%%"
set datafile separator ","
plot 'test1.txt' using 2:xtic(f(stringcolumn(1))) title " CPU consumption (%) ", \
'' using 3 title " RAM consumption (%)", \
'' using 0:($2+1):(sprintf(" %g%%",$2)) with labels notitle, \
'' using 0:($3+1):(sprintf(" %g%%",$3)) with labels notitle
Here is an example of a graph that does not work properly because the percentages are too shifted :
I am able to change this by changing this line in my code:
'' using 0:($3+1):(sprintf(" %g%%",$3)) with labels notitle
To :
'' using 0:($3+1):(sprintf(" %g%%",$3)) with labels notitle
Adding spaces allows to shift the percentages :
But even if it works for this graph, it moves the percentages for the other graphs too... :
I can't get "clean" graphics. Either the percentages overlap, or they go out of scope because the values are too large, or they are completely shifted....
Another example:
Is there a way to make all this move by itself, automatically, according to the values and therefore the size of the bars etc?
You might try an alternative mechanism, using plot for [i=2:3] ... to loop through the 2 columns of values. Instead of guessing the number of spaces to indent, you estimate the x position of the bar using column(0)+(i-2)*.25 (for i = 2 then 3),
which I got to by trial and error.
For example, using a function mytitle to get the 2 titles (my gnuplot is too old for an array):
mytitle(x) = (x==2?"cpu":"ram")
plot for [i=2:3] 'data' using i:xtic(stringcolumn(1)) title mytitle(i), \
for [i=2:3] '' using (column(0)+(i-2)*.25):(column(i)+1):\
(sprintf("%g%%",column(i))) with labels notitle
I have the following gnuplot inputfile plot.gpi
#!/bin/env gnuplot
set term postscript enhanced
set output "h_CH.eps"
set encoding utf8
set ylabel "HFC value in MHz"
set title "HFC for H in CH"
set yrange [-48:-45.8]
plot -47.6926 title "CBS" lw 2, \
"data" using 1:xtic(2) with linespoints pt 4 ps 2 lw 2 title "pcH-n"
and a data file data containing:
-46.0170, pcH-1
-47.3122, pcH-2
-47.7706, pcH-3
-47.6692, pcH-4
The results using gnuplot 5.1 is the following:
I would like to have some spacing before the data is plotted. I have tried adding "dummy points" to the data file like this:
0,
-46.0170, pcH-1
0,
-47.3122, pcH-2
0,
-47.7706, pcH-3
0,
-47.6692, pcH-4
0,
Which results in this
As you can see, the points are not connected.
My question is: does there exist a way to tell gnuplot to "indent" or insert horizontal spacing before the data is plotted?
So, I am playing around with gnuplot, and it somehow behaves weird. here is the full code:
reset
#set terminal cairolatex pdf input
#set output 'test.tex'
set terminal wxt
poisson(n) = nexp**n/int(n)!*exp(-nexp)
nexp = 3
ax = nexp
ay = 1
bw = 0.2
set xrange[-0.5:12.5]
set samples 13
#set style data boxes
set boxwidth bw absolute
set style fill transparent solid 0.5 border
set xtics 1
set xlabel '$n$'
set ylabel 'Probabiltity of finding $n$ photons'
set key off
plot '+' using (ax+bw/2):(ay) with boxes lc rgb"green" title 'Fock state with $n = 3$',\
'+' using ($0-bw/2):(poisson($0)) with boxes lc rgb"blue" title 'Coherent state with $\langle n \rangle = 3$'
This is the output I get:
For some reason the green box is not transparent in the plot, but transparent in the key. Anyone knows why or how to solve it?
Thanks a lot for any tips.
You generate 13 samples and plot 13 boxes at the sample place. Of course you don't see the transparency anymore. Change the first part of your plot command to draw a single box only:
plot '+' using (ax+bw/2):($0 == 0 ? ay : 1/0) with boxes lc rgb "green"
How do I draw different types of lines on gnuplot? I got to draw different colors. My script joins several files and I think it is why the lines are not dash. Only two of four are dashed.
Thanks
Felipe
#!/usr/bin/gnuplot
set grid
set title 'Estado dos arquivos no BTRIM com peers de comportamento condicionado'
set xlabel 'Tempo discreto'
set ylabel 'Quantidade de arquivos'
set style line 1 lc rgb '#0060ad' lt 1 lw 2 pi -1 ps 1.0
set style line 2 lc rgb '#dd181f' lt 9 lw 2 pi -1 ps 1.0
set style line 3 lc rgb '#29c524' lt 6 lw 2 pi -1 ps 1.0
set style line 4 lc rgb '#7D72F9' lt 7 lw 2 pi -1 ps 1.0
set style line 5 lc rgb '#000000' lt 8 lw 2 pi -1 ps 1.0
set termoption dashed
#set pointintervalbox 0
#set boxwidth 0.1
#set style fill solid
plot '<paste ../00/StatisticNormal.txt ../01/StatisticNormal.txt ../02/StatisticNormal.txt ../03/StatisticNormal.txt ../04/StatisticNormal.txt ../05/StatisticNormal.txt ../06/StatisticNormal.txt ../07/StatisticNormal.txt ../08/StatisticNormal.txt ../09/StatisticNormal.txt' smooth unique with line ls 1 title 'Normais', \
'<paste ../00/StatisticVogue.txt ../01/StatisticVogue.txt ../02/StatisticVogue.txt ../03/StatisticVogue.txt ../04/StatisticVogue.txt ../05/StatisticVogue.txt ../06/StatisticVogue.txt ../07/StatisticVogue.txt ../08/StatisticVogue.txt ../09/StatisticVogue.txt' smooth unique with line ls 2 title 'na Moda', \
'<paste ../00/StatisticPopular.txt ../01/StatisticPopular.txt ../02/StatisticPopular.txt ../03/StatisticPopular.txt ../04/StatisticPopular.txt ../05/StatisticPopular.txt ../06/StatisticPopular.txt ../07/StatisticPopular.txt ../08/StatisticPopular.txt ../09/StatisticPopular.txt' smooth unique with line ls 3 title 'Populares', \
'<paste ../00/StatisticRarity.txt ../01/StatisticRarity.txt ../02/StatisticRarity.txt ../03/StatisticRarity.txt ../04/StatisticRarity.txt ../05/StatisticRarity.txt ../06/StatisticRarity.txt ../07/StatisticRarity.txt ../08/StatisticRarity.txt ../09/StatisticRarity.txt' smooth unique with line ls 4 title 'Raros'
pause -1
Until version 4.6
The dash type of a linestyle is given by the linetype, which does also select the line color unless you explicitely set an other one with linecolor.
However, the support for dashed lines depends on the selected terminal:
Some terminals don't support dashed lines, like png (uses libgd)
Other terminals, like pngcairo, support dashed lines, but it is disables by default. To enable it, use set termoption dashed, or set terminal pngcairo dashed ....
The exact dash patterns differ between terminals. To see the defined linetype, use the test command:
Running
set terminal pngcairo dashed
set output 'test.png'
test
set output
gives:
whereas, the postscript terminal shows different dash patterns:
set terminal postscript eps color colortext
set output 'test.eps'
test
set output
Version 5.0
Starting with version 5.0 the following changes related to linetypes, dash patterns and line colors are introduced:
A new dashtype parameter was introduced:
To get the predefined dash patterns, use e.g.
plot x dashtype 2
You can also specify custom dash patterns like
plot x dashtype (3,5,10,5),\
2*x dashtype '.-_'
The terminal options dashed and solid are ignored. By default all lines are solid. To change them to dashed, use e.g.
set for [i=1:8] linetype i dashtype i
The default set of line colors was changed. You can select between three different color sets with set colorsequence default|podo|classic: