【问题标题】:gnuplot: 2D plot of a matrix of datagnuplot:数据矩阵的二维图
【发布时间】:2015-09-08 13:10:23
【问题描述】:

如何在 Gnuplot 中绘制(二维图)具有这种数据结构的矩阵,使用第一行和第一列作为 x 和 y 刻度(第一行的第一个数字是列数)并表示其余部分颜色映射的值,以便可以在 2D 平面上看到?

4 0.5 0.6 0.7 0.8
1 -6.20 -6.35 -6.59 -6.02
2 -6.39 -6.52 -6.31 -6.00
3 -6.36 -6.48 -6.15 -5.90
4 -5.79 -5.91 -5.87 -5.46

【问题讨论】:

    标签: gnuplot


    【解决方案1】:

    您可以使用matrix nonuniform 绘制此数据格式。

    要获得热图,您可以绘制 with image(规则网格,无插值,每个数据点一个四边形)或 splot with pm3d(也支持不规则网格和插值,为四个相邻数据点绘制一个四边形.

    1. with image

      set autoscale xfix
      set autoscale yfix
      set autoscale cbfix
      plot 'data.dat' matrix nonuniform with image notitle
      

    1. pm3d

      set autoscale xfix
      set autoscale yfix
      set autoscale cbfix
      set pm3d map
      splot 'data.dat' matrix nonuniform notitle
      

    【讨论】:

    • 谢谢它的工作。我试图用 splot 'data.txt' 和 matrix 来做到这一点,它给了我作为索引的列数和行数。
    • 不,“with matrix”只是语法错误,“with”需要一种绘图风格。数据格式的诀窍是matrix nonuniform
    • 我们如何将数据包含在热图中 - 要插入的数据的每个值在网格上对应的(x,y) 位置?
    • @Gathide 为此使用labels 绘图样式,请参见例如stackoverflow.com/a/27049991/2604213
    • 在这样的情节中,总是有不同颜色的正方形。我可以用不同颜色的点(圆点)得到同样的图吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多