【问题标题】:gnuplot: superimposing contour plot and data on x-y planegnuplot:在 x-y 平面上叠加等高线图和数据
【发布时间】:2015-01-13 22:56:54
【问题描述】:

我是 gnuplot 的新手。我正在尝试在 x-y 平面上叠加等高线图和一些数据点。

我的轮廓数据已给出 (surface1.txt) here
给定单点数据 (points1.txt) here

我正在尝试运行此脚本:

set multiplot
# plot the contour from the surface1.txt
unset key
set dgrid3d
unset surface
set contour base
# these values need to be set (requirement)
set cntrparam level incremental 0.16, 0.259, 4.47
set view 0,0
unset ztics
splot "surface1.txt" with lines
# plot the points on the x-y plane
unset xtics
unset ytics
splot "points1.txt"
unset multiplot

我得到了这个输出:

如你所见,我试图放在 x-y 平面上的单点也作为轮廓,我需要做的是:

  1. 将“points1.txt”中的点显示为单个点(不是轮廓)
  2. 情节已缩小,我需要全屏图像。
  3. 将 y 轴刻度从右向左垂直移动。
  4. 删除所有颜色。我需要一张灰度图。

请帮忙。

编辑: 这种方式我也试过--

set contour base
set cntrparam bspline
set cntrparam level incremental 0.16, 0.259, 4.47
set view map
set dgrid3d
unset key
splot 'surface1.txt' nosurface with lines, \
    'points1.txt' nocontour

我得到了这个情节--

【问题讨论】:

    标签: plot gnuplot contour


    【解决方案1】:

    您必须注意几件事:

    1. set dgrid3d 对您的数据进行插值,并被认为用于非网格数据。没有选项nodgrid3d 允许您仅将它用于一个情节部分。这是您在第二次尝试中看到的内容:对点的数据进行插值并生成一个 10x10 的网格。

      但是,您不需要使用它,因为您有网格化数据,但在数据文件中缺少几行空行。当 x 值发生变化时,只需插入一个空行,例如:

      ...
      0.0 0.7999999999999999  2.0477812692428836
      0.0 0.8999999999999999  2.3096674656635523
      0.0 0.9999999999999999  2.5772908911794614
      
      0.1 0.0 0.8254201558219569
      0.1 0.1 1.0350909705482707
      0.1 0.2 1.2504990143698247
      ...
      
    2. 对等高线使用nosurface 选项,在绘制点时使用nocontours

    一个可能的脚本可能是:

    set contour base
    set cntrparam level incremental 0.16, 0.259, 4.47
    unset key
    set view map
    set for [i=1:20] linetype i lc rgb 'black'
    
    set terminal pngcairo dashed size 600,400
    set output 'contour-with-points.png'
    splot 'surface1.txt' with lines nosurface, 'points1.txt' with points nocontour pt 7
    

    结果

    我仅在此示例中使用了pngcairo 终端,对于您的文档,您可能应该使用矢量格式,例如由 pdfcairo、postscript、epslatex 或类似文件生成。

    【讨论】:

    • 这行得通!谢谢。但是set for [i=1:20] linetype i lc rgb 'black' 还有其他方法吗?因为我不确定是否会有 20 行。
    • 您可以将set linetype 1 lc rgb 'black'; set linetype cycle 1 与版本 4.6.5 一起使用。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-27
    • 2023-02-04
    • 1970-01-01
    • 2021-12-21
    • 2018-11-19
    • 2015-01-16
    相关资源
    最近更新 更多