| Date: Thu, 22 Apr 2021 21:47:41 +0200
granular2img.1: elaborate and improve examples
Diffstat:
M granular2img.1 | 40 ++++++++++++++++++++++++++++---
1 file changed, 37 insertions(+), 3 deletions(-)
--- |
| t@@ -15,8 +15,10 @@ The
.Nm
utility reads
.Xr granular 5
-formatted data and plots grains as an image file, e.g. pdf (default),
-written to stdout.
+formatted data and plots grains as an image file, pdf format by default,
+and writes it to stdout.
+The common use is to pipe the stdout to a file or a suitable program
+which accepts the format as stdin.
.Pp
The options are as follows:
.Bl -tag -width Ds
t@@ -47,20 +49,52 @@ successful exit
unspecified error
.El
.Sh EXAMPLES
+Read a file (packing.tsv) in
+.Xr granular 5
+format and save an image of it in pdf format:
+.Pp
+.Dl $ granular2img < packing.tsv > out.pdf
+.Pp
+Read output from
+.Xr granularpacking 1
+and plot it and save the result as a PNG file:
+.Pp
.Dl $ granularpacking | granular2img -t png > out.png
.Pp
+Color the grains according to the second field in the
+.Xr granular 5
+format, which is x position, set a suitable colorbar label, and open it
+directly in the PDF viewer
+.Xr zathura 1 :
+.Pp
.Bd -literal -offset indent
$ granularpacking | granular2img -f '$2' -l 'x pos. [m]' \\
| zathura -
.Ed
+.Pp
+Same as the previous example, but color grains according to the product
+of x and y position:
+.Pp
.Bd -literal -offset indent
$ granularpacking | granular2img -f '$2*$3' -l 'x*y pos. [m]' \\
| zathura -
.Ed
.Pp
-.Dl $ granular2img < packing.tsv > out.pdf
+Loop over all output files from
+.Xr granular 1
+simulation "test", save them as images, and combine them into a video
+animation:
+.Pp
+.Bd -literal -offset indent
+$ for f in test.grain.*.tsv; do \\
+ granular2img -t png < "$f" > "${f%.tsv}.png"; \\
+ done && \\
+ ffmpeg -i test.grain.%05d.png \\
+ -c:v libx264 -vf fps=10 -pix_fmt yuv420p test.mp4
+.Ed
.Sh SEE ALSO
.Xr awk 1 ,
+.Xr ffmpeg 1 ,
.Xr gnuplot 1 ,
.Xr granular2vtu 1 ,
.Xr granular 5 |