I am getting the following error while plotting graph in gnuplot 4.4
gnuplot> set style fill transparent pattern 2 noborder
^
"./clusterload_all.pg", line 16: ';' expected
Also some errors like this :
gdImageStringFT: Could not find/open font while printing string 45 with font Arial
gnuplot> plot "cpu.dat" using 1:2 with lines title "CPU% total" lw 5 lc 1,
'' using 1:3 with lines title "MEM% total" lw 5 lc 2,
'' using 1:4 with lines title "CPU% for clmServer" lw 5 lc 6,
'' using 1:5 with lines title "MEM% for clmServer" lw 5 lc 10,
'' using 1:8 with boxes fill transparent pattern 2 title "1: Uninstall Licenses" lw 2 lc 5,
'' using 1:9 with boxes fill transparent pattern 2 title "2: Install Licenses" lw 2 lc 6,
'' using 1:10 with boxes fill transparent pattern 2 title "3: Query Installed Licenses" lw 2 lc 7,
'' using 1:11 with boxes fill transparent pattern 2 title "4: Creating Feature Codes" lw 2 lc 11,
'' using 1:12 with boxes fill transparent pattern 2 title "5: Register Feature Codes" lw 2 lc 3,
'' using 1:13 with boxes fill transparent pattern 2 title "6: Query Feature Codes" lw 2 lc 1,
'' using 1:14 with boxes fill transparent pattern 2 title "7: Unregister Feature Codes" lw 2 lc 21
^
"./clusterload_all.pg", line 29: ';' expected
Could anyone please help me regarding this.
To manage the error you need to understand what happens in the line that generated it.
Gnuplot interpreter gives an help signing with the cursor "^" the first letter of the offending word and writing the line number where it is possible to find it (the line number if a script is loaded with load "myscript.gp" or gnuplot is invoked by command line asgnuplot myscript.gp).
The origin can be various since, until that offending word, the syntax seems to be acceptable.
Let me cite just a few examples:
A not correct order in the option sequence
plot "<seq 1 20" with lines using 0:($1) # before "using" after "with"
A line currently accepted by a version of gnuplot but not from a different one (that differs not only for version or subversion number, but even only for compilation option)
Note: with the use of the backslash(\) it's possible to split on different lines a long long command as if it was written in a single line. It's cosy and clean especially in a script.
When the error is generated the output of this long long line is recomposed so the column of the cursor(^) can appear wrong if compared with the position of the offending word in the script.
To reproduce your specific error we can check only the kernel of your command with some different version of gnuplot.
set style fill transparent pattern 2 noborder
With the results reported below:
in gnuplot 4.1.0 and it gives me the same error message
gnuplot> set style fill transparent pattern 2 noborder
^
';' expected
in gnuplot 4.6.3 I have no error at all.
in a gnuplot linux Version 4.4 patchlevel 0 (last modified March 2010) with no error.
If you avoid the feature transparent you will avoid the error in the older version too (4.1.0).
Please verify once again the version you have on your system...
...and feel you free to update it as you can :-) it's rather old.
More seriously if you cannot upload the version you use, you can take hints about the past syntax from the old demo (i.e. http://gnuplot.sourceforge.net/demo_4.4/ )... or from the older ones. Usually there is backward compatibility, meanwhile the forward compatibility is more difficult to find.
ps> You can write that long command line from the internal interpreter or in a more cosy way you can write it in an external file (a script). You can load the script in gnuplot or with the command load "./clusterload_all.pg" inside the gnuplot interpreter or you can call with the command line gnuplot -persist ./clusterload_all.pg from the shell prompt.
Related
I would like a way to completely reset a gnuplot session from within gnuplot; exactly equivalent to exiting and restarting.
The commands reset or reset session (http://www.bersch.net/gnuplot-doc/reset.html) are not sufficient, since some options that were set before linger after either command (e.g., set term, set output, ...).
Note that the solution to how to completely reset gnuplot? is not sufficient for my purposes.
For context, the problem I am having is that I often use the same terminal session to execute many different gnuplot scripts to make many different plots. For some of those plots I want to simply use default options, while for others I prefer to be more specific. If I run one of the more "specific" scripts before I run one of the "default" scripts many of the "specific" settings are applied to the "default" plot, even when each script begins with a reset session command. My current solution is to manually restart gnuplot, which is a bit annoying.
The following minimal script illustrates an example of the problem: After running both the reset and reset session commands the terminal is not reset to whatever the default is. Here by 'default' I mean whatever terminal loads up when it starts, in my case qt. Note that the terminal type is just one example of a number of things that linger after the reset commands. I want some way of restoring gnuplot to exactly the state it starts in.
show terminal
set terminal pdfcairo
show terminal
reset
reset session
show terminal
I don't think the hard reset you mention is provided by gnuplot.
As your example shows, it seems to be difficult to do an exact reset with the reset session.
As a workaround, you might try the following method using an initialization script.
help reset says,
The following are not affected by reset:
set term set output set loadpath set linetype set fit
set encoding set decimalsign set locale set psdir
set overflow set multiplot
And, help reset session mentions also like this,
reset session deletes any user-defined variables and functions, restores
default settings, and then re-executes the system-wide gnuplotrc initialization
file and any private $HOME/.gnuplot or $XDG_CONFIG_HOME/gnuplot/gnuplotrc
preferences file. See initialization.
According to this behavior, I recommend that you write the default settings you need in the initialization file "$HOME/.gnuplot" that will be called when you do reset session.
Here are the steps to do so:
(1) Invoke gnuplot with the -d option.
(2) Run command save "settings.plt" to save the current settings to "settings.plt".
(3) Extract the necessary settings from the contents of "settings.plt".
Here is the case in my environment (it may be different in yours).
set terminal x11 nopersist enhanced
set output
set loadpath
set fit brief errorvariables nocovariancevariables errorscaling prescale nowrap v5
set encoding default
unset decimalsign
set locale "C"
set psdir
The save command does not write out the configuration of the linetype, it needs to be examined separately.
(4) Run command show linetype to find out the default settings of the linetype.
linetype 1, linecolor rgb "red" linewidth 1.000 dashtype solid pointtype 1 pointsize default
linetype 2, linecolor rgb "#009e73" linewidth 1.000 dashtype solid pointtype 2 pointsize default
linetype 3, linecolor rgb "#56b4e9" linewidth 1.000 dashtype solid pointtype 3 pointsize default
linetype 4, linecolor rgb "#e69f00" linewidth 1.000 dashtype solid pointtype 4 pointsize default
linetype 5, linecolor rgb "#f0e442" linewidth 1.000 dashtype solid pointtype 5 pointsize default
linetype 6, linecolor rgb "#0072b2" linewidth 1.000 dashtype solid pointtype 6 pointsize default
linetype 7, linecolor rgb "#e51e10" linewidth 1.000 dashtype solid pointtype 7 pointsize default
linetype 8, linecolor rgb "black" linewidth 1.000 dashtype solid pointtype 8 pointsize default
Linetypes repeat every 8 unless explicitly defined
See help linetype for more information on how to write it.
(5) Write them in "$HOME/.gnuplot".
What is the reason that lw 0 doesn't have zero linewidth, i.e. invisible?
What I find in the gnuplot manual:
The line width and point size are multipliers for the current
terminal's default width ...
Ok, if lw 0 is a multiplier then the resulting linewidth should be zero independent of the terminal's default linewidth.
The reason for asking is to eventually have the possibility to use with linespoints and programmatically switch within a loop between with lines and with points.
Code:
### linewidth 0 isn't zero
reset session
set key out
set yrange[-0.9:10.9]
set ytics 1
plot for [i=0:10] i with lines lw i title sprintf("linewidth %g",i)
### end of code
Result:
By the way, what are the artefacts at the y-axis e.g. at ytics 3,4,6,7,9,10 (wxt-terminal)?
Mike Nakis is correct that for at least some of the gnuplot output terminals, including PostScript, gnuplot asks for a 0 width line and the language or library in question interprets that as "1 pixel" or "thinnest possible line".
Similarly "pointtype 0" is not truly missing, it produces a single pixel dot.
You can, however, disable the line drawing altogether by using linetype "nodraw".
That gives a complementary pair of commands
plot sin(x) with linespoints lt nodraw pt 7 # only the points are visible
plot sin(x) with linespoints lt 1 pt 0 # only the lines are visible
In some circumstances it may help to know that the numeric equivalent for lt nodraw is lt -2.
I don't know for sure what the official explanation is for gnuplot in particular, but in my experience, most graphics packages / tools / libraries etc. use a special convention for a line width of zero.
According to this convention, a line width of zero does not mean invisible; it simply means "the thinnest line possible". This means the thinnest line that can be displayed on the device, regardless of zoom, transformations, logical-to-physical mapping, etc.
So, on monitors, it will be a line which is one pixel wide.
On a printer, it will be the thinnest line that the printer is capable of producing. So, if the printer has a high enough resolution, then the line might practically be invisible, though a magnifying glass should still be able to reveal its existence.
And note that "regardless of zoom, etc." means that even if you set up some scaling that makes your 10-point line look as thick as 100 pixels, the zero-width line will still be exactly one pixel thick.
I am trying to plot a dotted line within an splot with the following code in Gnuplot 4.6 patchlevel 4:
set terminal "pdfcairo" enhanced dashed size 15,10
set pm3d map
set output "test.pdf"
splot 'map.dat' using 1:($2/1000):3 notitle, \
'line1.dat' using 1:($2/1000):1 notitle with lines ls 2, \
'line2.dat' using 1:($2/1000):1 notitle with lines ls 2
unset output
The heat map works and so does line1.dat. However, the second line appears mostly solid. The difference is that line1.dat has 70 entries and line2.dat has 900. The second line has a jump between two points and there it is dotted.
Does somebody know how I can change the dot density so that the whole line appears dotted. Changing the original data file is not an option.
Thank you for your help,
noes
EDIT:
One workaround I found is
splot 'line2.dat' every ...
but that can get unconvenient at the jump in the data.
The command (s)plot 'line.dat' with lines first plots the datapoints and then connects the datapoints using lines with the respective linestyle. If the datapoints are too close to each other, there is no place for some gaps when a dashed linestyle is used.
To display a dotted/dashed line, you can try to replace the points by a function or to reduce the number of points.
Try dotted lines instead of dashed lines. Linestyle and linecolor can be set independently: splot 'line.dat' with lines ls 0 lc 2. 900 points might be too many for this approach.
Fitting a function would work, but probably it is too difficult to find a suitable function.
The every option reduces the number of points.
Another possibility to reduce the number of points would be to interpolate the points using the smooth option. This requires a temporary file and works as follows:
# [prepare plot]
set samples 100
set table "line2.dat.tmp"
plot 'line2.dat' using 1:($2/1000) smooth mcsplines with lines ls 2
unset table
set terminal "pdfcairo" enhanced dashed size 15,10
set pm3d map
set output "test.pdf"
# [plot]
splot 'map.dat' using 1:($2/1000):3 notitle, \
'line1.dat' using 1:($2/1000):1 notitle with lines ls 2, \
'line2.dat.tmp' using 1:2:1 notitle with lines ls 2
unset output
In the [prepare plot] section a temporary file "line2.dat.tmp" is created which contains datapoints interpolating line2.dat. You have to play with set samples to get the right number of points. In the example we have 100 equidistant points instead of 900 points with different distances.
The option smooth mcsplines preserves the monotonicity and convexity of the original data points, see help smooth mcsplines in a gnuplot shell.
In the [plot] section the original "lines2.dat" is replaced by the interpolated data.
This approach works if the original data is smooth enough so that replacing 900 points by 100 points does not skip important information. Maybe you want to plot both "lines2.dat" and "lines2.dat.tmp" in a single diagram to compare them.
User the every key-word, like this:
'line2.dat' every 20 using 1:($2/1000):1 notitle with lines ls 2
Here's my minimal Gnuplot script:
data="3.000000\t49.200000\n3.500000\t42.800000\n4.000000\t37.800000\n4.500000\t33.800000\n5.000000\t30.400000\n5.500000\t28.000000\n"
plot '< echo -e '.sprintf('"%s"', data) using 1:2 title 'there is no data point for x=3.0?' w linespoints
In my actual script, of course, I populate the data string in a different way (using the stats command), so saving the data to a file first, then running plot should work, but I don't like it! Seems overly cumbersome, leaves stray files around, etc.
My current solution is to prepend the string with a dummy line (data="0\t0\n..."), but my concern is: am I doing something wrong, or is this a bug?
(I'm on ubuntu 14.04, gnuplot 4.6 patchlevel 4, which I guess is not the super-most-up-to-date...)
Thanks!
Remove the -e option and it works fine:
data="3.000000\t49.200000\n3.500000\t42.800000\n4.000000\t37.800000\n4.500000\t33.800000\n5.000000\t30.400000\n5.500000\t28.000000\n"
plot '< echo '.sprintf('"%s"', data) using 1:2 title 'there is a data point for x=3.0!' w linespoints
But I can't tell you exactly why it works ;)
As an outlook for you: Gnuplot 5 has a new way of saving inline data as some kind of heredoc. In my eyes it isn't a good way to include actual data files into the plotting script, but it is supported:
$data <<EOD
3.000000 49.200000
3.500000 42.800000
4.000000 37.800000
4.500000 33.800000
5.000000 30.400000
5.500000 28.000000
EOD
plot $data using 1:2 notitle w linespoints
I am using gnuplot for Windows using the default windows terminal. I need to plot a dashed line instead of normal solid line
I used
set style line 1 lt 0 lc 3
plot 'dashcca.txt'
but it does not work
Any suggestions?
See help terminal windows, which shows you the terminal option dashed. Either use
set terminal windows dashed
or
set termoption dashed
And of course you must use a line type which is dashed. Type test to see all supported line types with the current terminal settings.
In order to use a certain dash pattern with a different line color, use e.g.
plot x linetype 2 linecolor 1
This uses the dash pattern of line type 2, and the color of line type 1 (red). You can use arbitrary colors with linecolor rgb:
plot x linetype 2 linecolor rgb 'black', x**2 linetype 3 linecolor rgb '#bb0000'