如何在 Octave 中的散点图顶部绘制等高线曲线

how to plot countour curve on top of scatter plot in Octave

我正在使用 Octave plot() 函数在二维图形上绘制散点。然后我使用 contour() 函数在点的顶部绘制轮廓。但是 contour() 函数并没有重叠在点之上。发生的情况是散点图完全被等高线代替,即使我使用的是 HOLD ON 命令。 我有这样的东西:

plot();  %plot the x,y scatter plot
hold on; %hold on to be able to add to the plot
contour(); %Add the contour on top of the scatter plot

我想知道是否有人可以展示一些示例代码,他们可以展示这些代码以向现有绘图添加等高线。

谢谢

这是一个例子:

   x = [-10:0.1:10];
   y = x  .^ 2;
   z = x' * x;
   hold on;
   contour(x,y,z);
   plot(x,y);

会产生这张图(蓝色的你可以看到plot发出的抛物线)。