如何使用 GNUplot 绘制圆?
How do you draw a circle using GNUplot?
我想用 GNU plot 画一个直径为 0.06 的圆。我一直在寻找一段时间,找不到任何解决方案。只是一个简单的圆圈,如果它超出特定圆圈的边界,它将作为要绘制的点的指示器。
我需要这样的东西,但直径是 -0.06 到 0.06.
示例图片的代码如下:
gnuplot> set parametric
dummy variable is t for curves, u/v for surfaces
gnuplot> set size square
gnuplot> set xrange [-1:1]
gnuplot> set yrange [-1:1]
gnuplot> plot [0:2*pi] sin(t),cos(t)
使用此代码完成:
set terminal png size 1000,1000;
set output 'test.png';
set xrange [-0.06:0.06]
set yrange [-0.06:0.06]
set size square
set object 1 circle front at 0,0size 0.06 fillcolor rgb "black" lw 1
plot "data.txt", "data2.txt"
感谢@Christoph 为我指明了正确的方向。
使用对象是很好的解决方案,但只是作为补充:
以原点为圆心的圆的参数方程很简单:
(x(t) = r.cos(t), y(t) = r.sin(t))
其中 r 是圆的半径,t 是参数。
因此对于半径为 0.6 的圆,只需键入:
set parametric
set size square
set xrange [-1:1]
set yrange [-1:1]
plot [0:2*pi] 0.6*sin(t), 0.6*cos(t)
我想用 GNU plot 画一个直径为 0.06 的圆。我一直在寻找一段时间,找不到任何解决方案。只是一个简单的圆圈,如果它超出特定圆圈的边界,它将作为要绘制的点的指示器。
我需要这样的东西,但直径是 -0.06 到 0.06.
示例图片的代码如下:
gnuplot> set parametric
dummy variable is t for curves, u/v for surfaces
gnuplot> set size square
gnuplot> set xrange [-1:1]
gnuplot> set yrange [-1:1]
gnuplot> plot [0:2*pi] sin(t),cos(t)
使用此代码完成:
set terminal png size 1000,1000;
set output 'test.png';
set xrange [-0.06:0.06]
set yrange [-0.06:0.06]
set size square
set object 1 circle front at 0,0size 0.06 fillcolor rgb "black" lw 1
plot "data.txt", "data2.txt"
感谢@Christoph 为我指明了正确的方向。
使用对象是很好的解决方案,但只是作为补充:
以原点为圆心的圆的参数方程很简单:
(x(t) = r.cos(t), y(t) = r.sin(t))
其中 r 是圆的半径,t 是参数。
因此对于半径为 0.6 的圆,只需键入:
set parametric
set size square
set xrange [-1:1]
set yrange [-1:1]
plot [0:2*pi] 0.6*sin(t), 0.6*cos(t)