2010-04-07 21:19:15 +02:00
|
|
|
--- demo/ellipse.dem
|
|
|
|
+++ demo/ellipse.dem 2010-04-06 16:00:28.000000000 +0000
|
|
|
|
@@ -9,6 +9,7 @@ if ((GPVAL_VERSION == 4.3 || GPVAL_VERSI
|
|
|
|
print "This copy of gnuplot was built without support for placing ellipses\n" ; \
|
|
|
|
exit ;
|
|
|
|
|
|
|
|
+random="`mktemp /tmp/random.XXXXXX`
|
|
|
|
|
|
|
|
unset key
|
|
|
|
set xrange [-8:8]
|
|
|
|
@@ -27,7 +28,7 @@ set object 1 ellipse center 1.5,1.0 size
|
|
|
|
set obj 2 ellipse center 1.5, 1 size 6, 12 angle 20 front fs empty bo 3
|
|
|
|
|
|
|
|
A = pi/9.
|
|
|
|
-plot 'random.tmp' using (1.5 + $1*cos(A)-2.*$2*sin(A)):(1.0 + $1*sin(A)+2.*$2*cos(A)) with dots
|
|
|
|
+plot random using (1.5 + $1*cos(A)-2.*$2*sin(A)):(1.0 + $1*sin(A)+2.*$2*cos(A)) with dots
|
|
|
|
|
|
|
|
pause -1 "Hit return to continue"
|
|
|
|
|
2009-06-15 16:35:00 +02:00
|
|
|
--- demo/fit.dem
|
2010-04-07 21:19:15 +02:00
|
|
|
+++ demo/fit.dem 2010-04-07 07:33:39.097446751 +0000
|
|
|
|
@@ -5,9 +5,11 @@
|
2007-09-06 22:19:11 +02:00
|
|
|
print "Some examples how data fitting using nonlinear least squares fit"
|
|
|
|
print "can be done."
|
|
|
|
print ""
|
2010-04-07 21:19:15 +02:00
|
|
|
+logfile = "`mktemp /tmp/fit.log.XXXXXX`"
|
2007-09-06 22:19:11 +02:00
|
|
|
pause -1 "first plotting the pure data set (-> return)"
|
|
|
|
|
2010-04-07 21:19:15 +02:00
|
|
|
reset
|
|
|
|
+set fit logfile logfile
|
2007-09-06 22:19:11 +02:00
|
|
|
set title 'data for first fit demo'
|
2010-04-07 21:19:15 +02:00
|
|
|
set xlabel "Temperature T [deg Cels.]"
|
|
|
|
set ylabel "Density [g/cm3]"
|
|
|
|
@@ -162,7 +164,7 @@ pause -1 "(-> return)"
|
2007-09-06 22:19:11 +02:00
|
|
|
# Must provide an error estimate for a 3d fit. Use constant 1
|
2009-06-15 16:35:00 +02:00
|
|
|
fit f(x,y) 'soundvel.dat' using 1:-2:2:(1) via 'sound.par'
|
2007-09-06 22:19:11 +02:00
|
|
|
#create soundfit.par, reading from sound.par and updating values
|
|
|
|
-update 'sound.par' 'soundfit.par'
|
2009-06-15 16:35:00 +02:00
|
|
|
+update 'sound.par' "`mktemp /tmp/soundfit.par.XXXXXX`"
|
2007-09-06 22:19:11 +02:00
|
|
|
print ""
|
|
|
|
pause -1 "(-> return)"
|
|
|
|
set title 'pseudo-3d multi-branch fit to velocity data'
|
2010-04-07 21:19:15 +02:00
|
|
|
@@ -251,6 +253,7 @@ print ""
|
|
|
|
pause -1 "Hit return to continue"
|
|
|
|
|
|
|
|
reset
|
|
|
|
+set fit logfile logfile
|
|
|
|
set xlabel 'x'
|
|
|
|
set ylabel 'y'
|
|
|
|
set zlabel 'z'
|
|
|
|
@@ -340,3 +343,4 @@ print "from time to time!"
|
|
|
|
print ""
|
|
|
|
pause -1 "Done with fitting demo (-> return)"
|
|
|
|
reset
|
|
|
|
+set fit logfile logfile
|
2009-06-15 16:35:00 +02:00
|
|
|
--- demo/poldat.dem
|
2010-04-07 21:19:15 +02:00
|
|
|
+++ demo/poldat.dem 2010-04-07 07:40:04.016079881 +0000
|
|
|
|
@@ -11,7 +11,7 @@ unset grid
|
2009-06-15 16:35:00 +02:00
|
|
|
unset polar
|
|
|
|
set title "Primitive Smith Chart"
|
2007-09-06 22:19:11 +02:00
|
|
|
unset key
|
2009-06-15 16:35:00 +02:00
|
|
|
-set xlabel "Impedance or Admittance Coordinates"
|
2010-04-07 21:19:15 +02:00
|
|
|
+set xlabel "Impedance or Admittance Coordinates" offset 12,-1
|
2009-06-15 16:35:00 +02:00
|
|
|
set para
|
|
|
|
set rrange [-0 : 10]
|
|
|
|
set trange [-pi : pi]
|
|
|
|
--- demo/random.dem
|
2010-04-07 21:19:15 +02:00
|
|
|
+++ demo/random.dem 2009-06-15 12:28:57.000000000 +0000
|
2009-06-15 16:35:00 +02:00
|
|
|
@@ -53,7 +53,8 @@ set parametric
|
|
|
|
# non-pressing plot-command feature addition may address this issue.
|
|
|
|
set samples nsamp
|
|
|
|
set format "%8.5g"
|
|
|
|
-set table "random.tmp"
|
|
|
|
+random="`mktemp /tmp/random.XXXXXX`"
|
|
|
|
+set table random
|
|
|
|
plot invnorm(rand(0)),invnorm(rand(0))
|
|
|
|
unset table
|
|
|
|
unset format
|
|
|
|
@@ -75,7 +76,7 @@ set vrange [-3:3]
|
|
|
|
set ticslevel 0
|
|
|
|
set isosamples 30
|
|
|
|
splot u,v,( 1/(2*pi) * exp(-0.5 * (u**2 + v**2)) ) with line lc rgb "black", \
|
|
|
|
- "random.tmp" using 1:2:(-0.2) with points pointtype 7 lc rgb "black"
|
|
|
|
+ random using 1:2:(-0.2) with points pointtype 7 lc rgb "black"
|
2007-09-06 22:19:11 +02:00
|
|
|
pause -1 "Hit return to continue"
|
2009-06-15 16:35:00 +02:00
|
|
|
unset contour
|
2007-09-06 22:19:11 +02:00
|
|
|
|
2009-06-15 16:35:00 +02:00
|
|
|
@@ -101,7 +102,7 @@ scale = (binwidth/(xhigh-xlow))
|
|
|
|
set parametric
|
|
|
|
set samples nsamp
|
|
|
|
set format "%8.5g"
|
|
|
|
-set table "random.tmp"
|
|
|
|
+set table random
|
|
|
|
plot invnorm(rand(0)),(1.0*scale/nsamp)
|
|
|
|
unset table
|
|
|
|
unset format
|
|
|
|
@@ -115,7 +116,7 @@ set grid
|
2007-09-06 22:19:11 +02:00
|
|
|
set xrange [-3:3]
|
2009-06-15 16:35:00 +02:00
|
|
|
set yrange [0:0.45]
|
|
|
|
bin(x) = (1.0/scale)*floor(x*scale)
|
|
|
|
-plot "random.tmp" using (bin($1)):2 smooth frequency with steps \
|
|
|
|
+plot random using (bin($1)):2 smooth frequency with steps \
|
|
|
|
title "scaled bin frequency", \
|
|
|
|
normal(x,0,1) with lines title "Gaussian p.d.f."
|
|
|
|
pause -1 "Hit return to continue"
|
|
|
|
@@ -136,7 +137,7 @@ set parametric
|
|
|
|
set samples nsamp
|
|
|
|
set isosamples 2,2 # Smallest possible
|
|
|
|
set format "%8.5g"
|
|
|
|
-set table "random.tmp"
|
|
|
|
+set table random
|
|
|
|
splot invnorm(rand(0)),invnorm(rand(0)),invnorm(rand(0))
|
|
|
|
unset table
|
|
|
|
unset format
|
|
|
|
@@ -158,7 +159,7 @@ set zzeroaxis lt -1
|
|
|
|
set view 68, 28, 1.4, 0.9
|
|
|
|
tstring(n) = sprintf("Gaussian 3D cloud of %d random samples\n", n)
|
|
|
|
set title tstring(nsamp) offset graph 0.15, graph -0.33
|
|
|
|
-splot "random.tmp" every :::::0 with dots
|
|
|
|
+splot random every :::::0 with dots
|
|
|
|
if (!oneplot) pause -1 "Hit return to continue"
|
2007-09-06 22:19:11 +02:00
|
|
|
|
2009-06-15 16:35:00 +02:00
|
|
|
unset parametric
|
|
|
|
@@ -178,7 +179,7 @@ scale = (binwidth/(xhigh-xlow))
|
|
|
|
set xrange [0:xhigh]
|
|
|
|
set yrange [0:0.65]
|
|
|
|
bin(x) = (1.0/scale)*floor(x*scale)
|
|
|
|
-plot "random.tmp" using (bin(sqrt($1**2+$2**2+$3**2))):(1.0*scale/nsamp) every :::::0 smooth frequency with steps \
|
|
|
|
+plot random using (bin(sqrt($1**2+$2**2+$3**2))):(1.0*scale/nsamp) every :::::0 smooth frequency with steps \
|
|
|
|
title "scaled bin frequency", \
|
|
|
|
maxwell(x, 1/sqrt(2)) with lines title "Maxwell p.d.f."
|
2007-09-06 22:19:11 +02:00
|
|
|
#
|
2010-04-07 21:19:15 +02:00
|
|
|
--- demo/simple.dem
|
|
|
|
+++ demo/simple.dem 2009-05-09 11:32:24.000000000 +0000
|
|
|
|
@@ -7,12 +7,11 @@
|
|
|
|
# gnuplot> load 'simple.dem'
|
|
|
|
#
|
|
|
|
set key left box
|
|
|
|
-set samples 50
|
|
|
|
+set samples 400
|
|
|
|
plot [-10:10] sin(x),atan(x),cos(atan(x))
|
|
|
|
pause -1 "Hit return to continue"
|
2007-09-06 22:19:11 +02:00
|
|
|
|
2010-04-07 21:19:15 +02:00
|
|
|
set key right nobox
|
|
|
|
-set samples 100
|
|
|
|
plot [-pi/2:pi] cos(x),-(sin(x) > sin(x+1) ? sin(x) : sin(x+1))
|
2007-09-06 22:19:11 +02:00
|
|
|
pause -1 "Hit return to continue"
|
|
|
|
|
2009-06-15 16:35:00 +02:00
|
|
|
--- demo/stringvar.dem
|
2010-04-07 21:19:15 +02:00
|
|
|
+++ demo/stringvar.dem 2009-06-15 12:46:14.000000000 +0000
|
2009-06-15 16:35:00 +02:00
|
|
|
@@ -1,7 +1,8 @@
|
2007-09-06 22:19:11 +02:00
|
|
|
#
|
2009-06-15 16:35:00 +02:00
|
|
|
# Miscellaneous neat things you can do using the string variables code
|
2007-09-06 22:19:11 +02:00
|
|
|
#
|
2009-06-15 16:35:00 +02:00
|
|
|
-set print "stringvar.tmp"
|
|
|
|
+stringvar="`mktemp /tmp/stringvar.XXXXXX`"
|
|
|
|
+set print stringvar
|
2009-05-28 04:44:00 +02:00
|
|
|
print ""
|
2009-06-15 16:35:00 +02:00
|
|
|
print "Exercise substring handling"
|
2007-09-06 22:19:11 +02:00
|
|
|
print ""
|
2009-06-15 16:35:00 +02:00
|
|
|
@@ -24,7 +25,7 @@ print "(foo.foo)[2:2]= ",(foo.foo)[2:2]
|
|
|
|
print ""
|
|
|
|
unset print
|
2007-09-06 22:19:11 +02:00
|
|
|
|
2009-06-15 16:35:00 +02:00
|
|
|
-set label 1 system("cat stringvar.tmp") at graph 0.1, graph 0.9
|
|
|
|
+set label 1 system(sprintf("cat %s", stringvar)) at graph 0.1, graph 0.9
|
|
|
|
unset xtics
|
|
|
|
unset ytics
|
|
|
|
set yrange [0:1]
|
|
|
|
@@ -33,7 +34,7 @@ plot 0
|
2007-09-06 22:19:11 +02:00
|
|
|
pause -1 "Hit return to continue"
|
|
|
|
|
|
|
|
|
2009-06-15 16:35:00 +02:00
|
|
|
-set print "stringvar.tmp"
|
|
|
|
+set print stringvar
|
|
|
|
print "Exercise string handling functions"
|
|
|
|
print ""
|
|
|
|
print "foo = ",foo
|
|
|
|
@@ -62,7 +63,7 @@ if (strlen(foo) != 245) print "sprintf o
|
|
|
|
print ""
|
2007-09-06 22:19:11 +02:00
|
|
|
|
2009-06-15 16:35:00 +02:00
|
|
|
unset print
|
|
|
|
-set label 1 system("cat stringvar.tmp") at graph 0.1, graph 0.9
|
|
|
|
+set label 1 system(sprintf("cat %s", stringvar)) at graph 0.1, graph 0.9
|
|
|
|
unset xtics
|
|
|
|
unset ytics
|
|
|
|
set yrange [0:1]
|
|
|
|
--- demo/vector.dem
|
2010-04-07 21:19:15 +02:00
|
|
|
+++ demo/vector.dem 2009-06-15 12:24:23.000000000 +0000
|
2009-06-15 16:35:00 +02:00
|
|
|
@@ -62,19 +62,21 @@ splot vtot(x,y) w l
|
|
|
|
print "Now create a file with equipotential lines"
|
2007-09-06 22:19:11 +02:00
|
|
|
pause -1 "Hit return to continue"
|
|
|
|
|
2009-06-15 16:35:00 +02:00
|
|
|
-set table "equipo2.tmp"
|
|
|
|
+equipo2="`mktemp /tmp/equipo2.XXXXXX`"
|
|
|
|
+set table equipo2
|
|
|
|
replot
|
|
|
|
unset table
|
|
|
|
reset
|
|
|
|
pause 0
|
|
|
|
|
|
|
|
-plot "equipo2.tmp" w l
|
|
|
|
+plot equipo2 w l
|
|
|
|
print "Now create a x/y datafile for plotting with vectors "
|
|
|
|
print "and display vectors parallel to the electrostatic field"
|
|
|
|
pause -1 "Hit return to continue"
|
|
|
|
set isosam 31,31
|
|
|
|
|
|
|
|
-set table "field2xy.tmp"
|
|
|
|
+field2xy="`mktemp /tmp/field2xy.XXXXXX`"
|
|
|
|
+set table field2xy
|
|
|
|
splot vtot(x,y) w l
|
|
|
|
unset table
|
|
|
|
pause 0
|
|
|
|
@@ -84,8 +86,8 @@ set xr [xmin:xmax]
|
|
|
|
set yr [ymin:ymax]
|
|
|
|
set isosam 31,31
|
|
|
|
set key under Left reverse
|
|
|
|
-plot "field2xy.tmp" u 1:2:(coef*dx1($1,$2)):(coef*dy1($1,$2)) w vec, \
|
|
|
|
- "equipo2.tmp" w l
|
|
|
|
+plot field2xy u 1:2:(coef*dx1($1,$2)):(coef*dy1($1,$2)) w vec, \
|
|
|
|
+ equipo2 w l
|
|
|
|
pause -1 "Hit return to continue"
|
|
|
|
|
|
|
|
reset
|
2010-05-12 18:26:55 +02:00
|
|
|
--- src/show.c
|
2010-05-25 14:35:23 +02:00
|
|
|
+++ src/show.c 2010-05-10 14:04:43.814925577 +0200
|
|
|
|
@@ -1054,6 +1054,15 @@ show_version(FILE *fp)
|
2010-05-12 18:26:55 +02:00
|
|
|
p /* hit 'h' */
|
|
|
|
);
|
|
|
|
|
|
|
|
+#ifdef GNUPLOT_LIB_DEFAULT
|
|
|
|
+ {
|
|
|
|
+ struct stat st;
|
|
|
|
+ if ((stat(GNUPLOT_LIB_DEFAULT, &st) == 0) && S_ISDIR(st.st_mode)) {
|
2010-05-25 14:35:23 +02:00
|
|
|
+ fprintf(fp, "\n%s\tType `load \"all.dem\"` to display a large number of examples.", p);
|
|
|
|
+ fprintf(fp, "\n%s\tThey are located at %s/*\n\n", p, GNUPLOT_LIB_DEFAULT);
|
2010-05-12 18:26:55 +02:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
/* show version long */
|
|
|
|
if (almost_equals(c_token, "l$ong")) {
|
2009-06-15 16:35:00 +02:00
|
|
|
--- src/variable.c
|
2010-04-07 21:19:15 +02:00
|
|
|
+++ src/variable.c 2009-06-15 12:01:39.000000000 +0000
|
2010-05-12 18:26:55 +02:00
|
|
|
@@ -37,7 +37,10 @@ static char *RCSid() { return RCSid("$Id
|
2010-04-07 21:19:15 +02:00
|
|
|
/* The Death of Global Variables - part one. */
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
-
|
|
|
|
+#include <stdio.h>
|
2010-05-12 18:26:55 +02:00
|
|
|
+#include <sys/types.h>
|
|
|
|
+#include <sys/stat.h>
|
|
|
|
+#include <unistd.h>
|
2010-04-07 21:19:15 +02:00
|
|
|
#include "variable.h"
|
|
|
|
|
|
|
|
#include "alloc.h"
|
2010-05-12 18:26:55 +02:00
|
|
|
@@ -95,6 +98,17 @@ loadpath_handler(int action, char *path)
|
2009-06-15 16:35:00 +02:00
|
|
|
if (!loadpath)
|
|
|
|
{
|
|
|
|
char *envlib = getenv("GNUPLOT_LIB");
|
|
|
|
+#ifdef GNUPLOT_LIB_DEFAULT
|
|
|
|
+ char *defenvlib = (char*)0;
|
2010-05-12 18:26:55 +02:00
|
|
|
+ struct stat st;
|
|
|
|
+ if ((stat(GNUPLOT_LIB_DEFAULT, &st) == 0) && S_ISDIR(st.st_mode)) {
|
|
|
|
+ if (envlib) {
|
|
|
|
+ if (asprintf(&defenvlib, "%s:%s", envlib, GNUPLOT_LIB_DEFAULT) > 0)
|
|
|
|
+ envlib = defenvlib;
|
|
|
|
+ } else
|
|
|
|
+ envlib = GNUPLOT_LIB_DEFAULT;
|
|
|
|
+ }
|
2009-06-15 16:35:00 +02:00
|
|
|
+#endif /* GNUPLOT_LIB_DEFAULT */
|
|
|
|
if (envlib) {
|
|
|
|
int len = strlen(envlib);
|
|
|
|
loadpath = gp_strdup(envlib);
|
2010-05-12 18:26:55 +02:00
|
|
|
@@ -103,6 +117,10 @@ loadpath_handler(int action, char *path)
|
2009-06-15 16:35:00 +02:00
|
|
|
/* convert all PATHSEPs to \0 */
|
|
|
|
PATHSEP_TO_NUL(loadpath);
|
|
|
|
} /* else: NULL = empty */
|
|
|
|
+#ifdef GNUPLOT_LIB_DEFAULT
|
|
|
|
+ if (defenvlib)
|
|
|
|
+ free(defenvlib);
|
|
|
|
+#endif /* GNUPLOT_LIB_DEFAULT */
|
|
|
|
} /* else: already initialised; int_warn (?) */
|
|
|
|
/* point to env portion of loadpath */
|
|
|
|
envptr = loadpath;
|