User:AnatolV/Helper Functions: Difference between revisions
Content added Content deleted
(updating preludes, adding 1 HFJS) |
(adding gnuplot sample, editing) |
||
Line 116: | Line 116: | ||
}//func end |
}//func end |
||
</lang> |
</lang> |
||
=PARI/GP Helper Functions= |
=PARI/GP Helper Functions= |
||
PARI/GP built-in plotting functions are good only for instant draft math function curves plotting. |
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> |
Not to mention bad color support and scaling.<br> |
||
In addition, there are no built-in string manipulation functions, except of concatenation.<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. |
So, presented here helper functions help to fix some of these shortcomings. At the same time, they simplify |
||
==Plotting Helper Functions== |
==Plotting Helper Functions== |
||
Many of these functions are already here on RC. |
Many of these functions are already here on RC. |
||
Line 158: | Line 159: | ||
\\ HFGP#5 iPlotmat() Improved simple plotting using matrix mat (color and scaling added). |
\\ HFGP#5 iPlotmat() Improved simple plotting using matrix mat (color and scaling added). |
||
\\ Matrix should be filled with 0/1. 7/6/16 |
\\ Matrix should be filled with 0/1. 7/6/16 |
||
\\ Writing a dump file fn according to the flag - dflg (0-no/1-yes). |
|||
⚫ | |||
\\ A dump file added mostly for the gnuplot plotting, also for re-plotting. |
|||
⚫ | |||
my(xz=#mat[1,],yz=#mat[,1],vx=List(),vy=vx,xmin,xmax,ymin,ymax,c=0.625); |
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)))); |
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); |
xmin=listmin(vx); xmax=listmax(vx); ymin=listmin(vy); ymax=listmax(vy); |
||
Line 166: | Line 171: | ||
plotpoints(0, Vec(vx)*c,Vec(vy)); |
plotpoints(0, Vec(vx)*c,Vec(vy)); |
||
plotdraw([0,xmin,ymin]); |
plotdraw([0,xmin,ymin]); |
||
print(" *** matrix: ",xz,"x",yz,", ",#vy," DOTS"); |
if (dflg==0, print(" *** matrix: ",xz,"x",yz,", ",#vy," DOTS")); |
||
} |
} |
||
Line 243: | Line 248: | ||
\\ SF#5 <<coming soon>> |
\\ 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> |
</lang> |