Is there any method to make a graph like following picture? In Gnuplot, have any command like "lineTo , moveTo , arc, ... etc"? If I want to produce some picture like this
What I should do for producing this picture? in turtle graphics, just need some codes
repeat 36 [rt 10 repeat 2 [fd 100 rt 90]]
You can do similar things with gnuplot. Of course, gnuplot needs to know the coordinates of the lines' start and end points, so you somehow have to calculate them. Something like the code below: you write the coordinates into a datablock and plot it with vectors
, also check help vectors
. Graph created with gnuplot 5.2.8.
Code:
### vector plot similar to turtle graphics
reset session
set size square
set angle degrees
x0 = 0
y0 = 0
a0 = 0
r0 = 10
set print $Data
do for [i=1:36] {
a0 = a0 - 10
do for [j=1:2] {
print sprintf("%g %g %g %g",x0,y0,x0=x0+r0*cos(a0),y0=y0+r0*sin(a0))
a0 = a0 - 90
}
}
set print
plot $Data u 1:2:($3-$1):($4-$2) w vectors nohead notitle
### end of code
Result:
Addition:
By the way: couldn't this turtle graphic command actually be simplified to?
repeat 36 [fd 100 rt 110]
Yes, as @Friedrich shows, it can be done without datablock.
Here is a modified version of my first shot without modulo %
. The fifth column, i.e. (x0=x0+r*cos(a),y0=y0+r*sin(a),a=a-110)
is not used for plotting, but just for calculation.
Code:
### vector plot similar to turtle graphics
reset session
set size square
set angle degrees
set xrange[-2:12]
set yrange[-10:4]
r = 10
set samples 36
plot a=x0=y0=0 '+' u (x0):(y0):(r*cos(a)):(r*sin(a)): \
(x0=x0+r*cos(a),y0=y0+r*sin(a),a=a-110) w vec nohead not
### end of code
Result: (similar to graph above)