Gnuplot 在放大时擦除圆圈

Gnuplot erases circles when zoomed in

我正在尝试使用 gnuplot 绘制一个数据文件以及 2 个圆圈。数据文件是here and the circle file is here。与数据集相比,圆圈相当大,当我大规模绘制它时,一切正常。但是当我尝试放大时,圆圈消失了。以下是我使用的 gnuplot 命令 (v5.4.2):

plot 'data.txt' us (log()):(log()) w lp, 'circ.txt' us 1:2:3 w circles

这是结果(看起来不错):

现在,如果我尝试放大一点(仍然可以):

set xrange [*:55]
replot

正在尝试放大更多(圆圈消失!)

set xrange [*:8]
replot

这是 gnuplot 中的错误,还是有办法解决这个问题并在放大视图中可视化圆圈?

Gnuplot 不会绘制超出范围的点。您可以将圆视为由圆心和半径定义的点。一旦中心超出范围,在这种情况下 xmin < xmax < center,圆就不再被绘制。

正如@Ethan 已经解释过的那样,使用绘图样式 with circles 如果圆心不再在图形范围内,则不会绘制圆。

如果您自己绘制圆圈,则可以解决此问题。然后只要圆周的数据点仍在图形中,您就可以放大。对于大放大,您可以增加样本数量,例如set samples 500.

但是,为了使圆在视觉上显示为圆(而不是椭圆),您必须 set size ratio -1 这将更改图形大小。

代码:

### plot circles which "allow" zoom-in
reset session
set size ratio -1

$Circles <<EOD
 50  0   50
100  0  100
220  0  220
EOD

CircX(x0,y0,r,t) = x0+r*cos(2*pi*t) 
CircY(x0,y0,r,t) = y0+r*sin(2*pi*t) 
x0(n) = word($Circles[n],1)
y0(n) = word($Circles[n],2)
r(n)  = word($Circles[n],3)

set key noautotitle
set samples 100
set yrange[-100:100]

plot for [i=1:|$Circles|] [0:1] '+' u \
    (CircX(x0(i),y0(i),r(i),)):(CircY(x0(i),y0(i),r(i),)) w l
### end of code

结果:(原图)

(放大):

另一个解决方案使用 'set object circle'

有一种方法可以使用 set object circle.

将 'circ.txt' 中定义的所有圆显示为对象
set table $DATA
plot "circ.txt" using 1:2:3 with table
unset table

do for [k=1:|$DATA|] {
   line = $DATA[k]
   xpos = word(line, 1)
   ypos = word(line, 2)
   r    = word(line, 3)
   set object circle at xpos, ypos radius r fill empty border lc black
}

set xrange [*:30]
set yrange [*:16]

plot "data.txt" using (log()):(log()) with lp