Jump to content

User:AnatolV/Helper Functions: Difference between revisions

adding gnuplot sample, editing
(updating preludes, adding 1 HFJS)
(adding gnuplot sample, editing)
Line 116:
}//func end
</lang>
 
=PARI/GP Helper Functions=
PARI/GP built-in plotting functions are good only for instant draft math function curves plotting.
Not to mention bad color support and scaling.<br>
In addition, there are no built-in string manipulation functions, except of concatenation.<br>
So, presented here helper functions help to fix some of these shortcomings. At the same time, they simplify
==Plotting Helper Functions==
Many of these functions are already here on RC.
Line 158 ⟶ 159:
\\ HFGP#5 iPlotmat() Improved simple plotting using matrix mat (color and scaling added).
\\ Matrix should be filled with 0/1. 7/6/16
\\ Writing a dump file fn according to the flag - dflg (0-no/1-yes).
iPlotmat(mat,clr)={
\\ A dump file added mostly for the gnuplot plotting, also for re-plotting.
iPlotmat(mat,clr,fn="dfn.dat",dflg=0)={
my(xz=#mat[1,],yz=#mat[,1],vx=List(),vy=vx,xmin,xmax,ymin,ymax,c=0.625);
\\ Dumping if requested (dflg=1).
if (dflg==1,wrtmat(mat, fn));
for(i=1,yz, for(j=1,xz, if(mat[i,j]==0, next, listput(vx,i); listput(vy,j))));
xmin=listmin(vx); xmax=listmax(vx); ymin=listmin(vy); ymax=listmax(vy);
Line 166 ⟶ 171:
plotpoints(0, Vec(vx)*c,Vec(vy));
plotdraw([0,xmin,ymin]);
if (dflg==0, print(" *** matrix: ",xz,"x",yz,", ",#vy," DOTS"));
}
 
Line 243 ⟶ 248:
 
\\ SF#5 <<coming soon>>
</lang>
 
=gnuplot Helper File-Functions=
File for the load command is the only possible imitation of the fine function in the '''gnuplot'''.<br><br>
'''plotff.gp''' - Plotting from any data-file with 2 columns (space delimited), and writing to png-file.<br>
Especially useful to plot colored fractals using points, also for re-plotting.
<br>
{{Works with|gnuplot|5.0 (patchlevel 3) and above}}
<lang gnuplot>
## plotff.gp 11/27/16 aev
## Plotting from any data-file with 2 columns (space delimited), and writing to png-file.
## Especially useful to plot colored fractals using points.
## Note: assign variables: clr, filename and ttl (before using load command).
reset
set terminal png font arial 12 size 640,640
ofn=filename.".png"
set output ofn
unset border; unset xtics; unset ytics; unset key;
set size square
dfn=filename.".dat"
set title ttl font "Arial:Bold,12"
plot dfn using 1:2 with points pt 7 ps 0.5 lc @clr
set output
</lang>
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.