/usr/share/doc/freefem++/examples/examples++-tutorial/gnuplot.edp is in freefem++-doc 3.19.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | int n=20,nn=n+10;
real[int] xx(nn),yy(nn);
mesh Th=square(5,5);
fespace Vh(Th,P2);
Vh uh=x*x+y*y,vh=-y^2+x^2;
assert(n+1 < nn);
// compute a cut
for (int i=0;i<=n;i++)
{
xx[i]=i;
yy[i]=uh(real(i)/n,real(i)/n); // value of uh at point (i/10. , i/10.)
}
plot(Th,uh,[uh,vh],value=true,ps="three.eps",wait=true); // plot mesh, isovalue, and vector
plot([xx(0:n),yy(0:n)],[xx(0:n:5),yy(0:n:5)],ps="likegnu.eps",wait=true); // like gnuplot plot a cut of uh
// file for gnuplot
{
ofstream gnu("plot.gp");
for (int i=0;i<=n;i++)
{
gnu << xx[i] << " " << yy[i] << endl;
}
}
// to call gnuplot command and wait 5 second (tanks to unix command)
// and make postscipt plot
exec("echo 'plot \"plot.gp\" w l \
pause 5 \
set term postscript \
set output \"gnuplot.eps\" \
replot \
quit' | gnuplot");
|