0

I am trying to draw a circle with an offset, in gnuplot. I can do that by adding the offset in the equations, as shown below. However, I want to do some more complicated rendering, e.g. render multiple circles each with a different angular offset around an offset origin. The script would be much more comprehensive if I do that by changing the origin of each circle's plot.

I am testing with a single circle:

set size square
set parametric
set xrange [-2:2]
set yrange [-2:2]
set trange [0:2*pi]
set multiplot

# circle centered at 0,0
fx(t) = sin(t)
fy(t) = cos(t)
plot fx(t), fy(t)

# circle centered at -1,-1
fx(t) = -1 + sin(t)
fy(t) = -1 + cos(t)
plot fx(t), fy(t)

# can't center this circle properly at 1,1
set origin 0.113, 0.23
fx(t) = sin(t)
fy(t) = cos(t)
plot fx(t), fy(t)

To achieve an offset of (1, 1), I have to use an origin of (0.113, 0.233). So, what is the equation that gives these coordinates? I have tried various sin/cos combinations since this might be related to polar coordinates, but no lack. The same exact situation occurs when using polar mode instead of parametric mode.

1 Answer 1

1

Check the online help about origin, it is a display option and not a plotting option.

There is no reason why this shouldn't work else. You can take inspiration from this code:

CENTER_X="1.5 3.2 -2.4"
CENTER_Y="-2.3 1.2 -0.4"
ANGLE="0 45 180"
RADIUS="1 1.2 0.8"
set parametric
set angle degrees
set trange [0:315]
set xrange [-6:6]
set yrange [-6:6]
set size ratio -1
set multiplot
unset key
do for [i=1:words(CENTER_X)] {
 plot word(CENTER_X,i)+word(RADIUS,i)*cos(word(ANGLE,i)+t),word(CENTER_Y,i)+word(RADIUS,i)*sin(word(ANGLE,i)+t)
}
unset multiplot
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.