Question:
I have a code, which hopefully makes a Sierpinski triangle, and I am wondering how can I output a data file that you read into gnuplot? I h
First of all, you have a couple of problems in your code:
x0 = 1.0; y0 = sqrt3;
should be x0 = sqrt3; y0 = 1.0;
instead.Once you output the points to a file called data
(I used System.out.println("" + x + " " + y);
within your loop), you can do the following in gnuplot:
set size ratio -1
plot "data" u 2:1 pt 7 ps 0.3
To monitor how the triangle gets created dot by dot you can use a loop with a pause:
set xrange [0:2]
set yrange [0:1.8]
do for [i=0:4999] {
plot "data" u 2:1 every ::::i pt 7 ps 0.3
pause 0.1
}
Or you can create an animated gif with a series of png files:
set term pngcairo
do for [i=0:4999] {
set output "".i.".png"
plot "data" u 2:1 every ::::i pt 7 ps 0.3
}
Expect the above to be slow. You can skip some of the frames to make it quicker. Then do this outside gnuplot:
convert -delay 10 -loop 0 *.png animation.gif
For this example I used 50 points increments and changed -delay
to 100: